COIN-OR::LEMON - Graph Library

Changeset 593:b83b36ee7f10 in lemon-0.x


Ignore:
Timestamp:
05/10/04 10:25:10 (16 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@772
Message:

comleteGraph

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/hugo/graph_wrapper.h

    r589 r593  
    466466    /// Returns true if \c n is hidden.
    467467    bool hidden(const Edge& e) const { return !(*edge_filter_map)[e]; }
     468
     469    /// This is a linear time operation an works only if
     470    /// NodeIt is defined.
     471    int nodeNum() const {
     472      int i=0;
     473      NodeIt n;
     474      for (this->first(n); this->valid(n); this->next(n)) ++i;
     475      return i;
     476    }
     477
     478    /// This is a linear time operation and works only if
     479    /// EdgeIt is defined.
     480    int edgeNum() const {
     481      int i=0;
     482      EdgeIt e;
     483      for (this->first(e); this->valid(e); this->next(e)) ++i;
     484      return i;
     485    }
     486
    468487  };
    469488
     
    13191338} //namespace hugo
    13201339
    1321 
    13221340#endif //HUGO_GRAPH_WRAPPER_H
    13231341
  • src/work/jacint/graph_gen.h

    r558 r593  
    6262  }
    6363
     64  /// Generates a complete graph in the undirected sense
     65  /// with n nodes and m edges.
     66  /// Before generating the random graph, \c g.clear() is called.
     67  template<typename Graph>
     68  void completeGraph(Graph& g, int n) {
     69    g.clear();
     70    std::vector<typename Graph::Node> nodes;
     71    for (int i=0; i<n; ++i)
     72      nodes.push_back(g.addNode());
     73    for (int i=0; i<n; ++i)
     74      for (int j=i+1; j<n; ++j)
     75        g.addEdge(nodes[i], nodes[j]);
     76  }
     77 
    6478} //namespace hugo
Note: See TracChangeset for help on using the changeset viewer.