gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Bug fixes in connectivity.h (#285) - Bug fix in tree(). - Rename simpleDigraph() to simpleGraph() (it works for both directed and undirected graphs). - Possibly faster implementation for parallelFree() and simpleGraph().
0 1 0
default
1 file changed with 20 insertions and 22 deletions:
↑ Collapse diff ↑
Show white space 6 line context
... ...
@@ -1372,2 +1372,3 @@
1372 1372
    typedef typename Graph::Arc Arc;
1373
    if (NodeIt(graph) == INVALID) return true;
1373 1374
    Dfs<Graph> dfs(graph);
... ...
@@ -1547,13 +1548,12 @@
1547 1548
  /// Returns true when there are not parallel edges in the graph.
1548
  template <typename Digraph>
1549
  bool parallelFree(const Digraph& digraph) {
1550
    typename Digraph::template NodeMap<bool> reached(digraph, false);
1551
    for (typename Digraph::NodeIt n(digraph); n != INVALID; ++n) {
1552
      for (typename Digraph::OutArcIt a(digraph, n); a != INVALID; ++a) {
1553
        if (reached[digraph.target(a)]) return false;
1554
        reached.set(digraph.target(a), true);
1549
  template <typename Graph>
1550
  bool parallelFree(const Graph& graph) {
1551
    typename Graph::template NodeMap<int> reached(graph, 0);
1552
    int cnt = 1;
1553
    for (typename Graph::NodeIt n(graph); n != INVALID; ++n) {
1554
      for (typename Graph::OutArcIt a(graph, n); a != INVALID; ++a) {
1555
        if (reached[graph.target(a)] == cnt) return false;
1556
        reached[graph.target(a)] = cnt;
1555 1557
      }
1556
      for (typename Digraph::OutArcIt a(digraph, n); a != INVALID; ++a) {
1557
        reached.set(digraph.target(a), false);
1558
      }
1558
      ++cnt;
1559 1559
    }
... ...
@@ -1567,15 +1567,13 @@
1567 1567
  /// the graph.
1568
  template <typename Digraph>
1569
  bool simpleDigraph(const Digraph& digraph) {
1570
    typename Digraph::template NodeMap<bool> reached(digraph, false);
1571
    for (typename Digraph::NodeIt n(digraph); n != INVALID; ++n) {
1572
      reached.set(n, true);
1573
      for (typename Digraph::OutArcIt a(digraph, n); a != INVALID; ++a) {
1574
        if (reached[digraph.target(a)]) return false;
1575
        reached.set(digraph.target(a), true);
1568
  template <typename Graph>
1569
  bool simpleGraph(const Graph& graph) {
1570
    typename Graph::template NodeMap<int> reached(graph, 0);
1571
    int cnt = 1;
1572
    for (typename Graph::NodeIt n(graph); n != INVALID; ++n) {
1573
      reached[n] = cnt;
1574
      for (typename Graph::OutArcIt a(graph, n); a != INVALID; ++a) {
1575
        if (reached[graph.target(a)] == cnt) return false;
1576
        reached[graph.target(a)] = cnt;
1576 1577
      }
1577
      for (typename Digraph::OutArcIt a(digraph, n); a != INVALID; ++a) {
1578
        reached.set(digraph.target(a), false);
1579
      }
1580
      reached.set(n, false);
1578
      ++cnt;
1581 1579
    }
0 comments (0 inline)