Loading...
Searching...
No Matches
Connectivity and Other Graph Properties
Algorithms

## Detailed Description

This group contains the algorithms for discovering the graph properties like connectivity, bipartiteness, euler property, simplicity etc.

## Classes

class | DiEulerIt< GR >
| Euler tour iterator for digraphs. More...
class | EulerIt< GR >
| Euler tour iterator for graphs. More...

## Files

file | connectivity.h
| Connectivity algorithms.
file | euler.h
| Euler tour iterators and a function for checking the Eulerian property.

## Functions

template<typename Graph>
bool | connected (const Graph &graph)
| Check whether an undirected graph is connected.
template<typename Graph>
int | countConnectedComponents (const Graph &graph)
| Count the number of connected components of an undirected graph.
template<class Graph, class NodeMap>
int | connectedComponents (const Graph &graph, NodeMap &compMap)
| Find the connected components of an undirected graph.
template<typename Digraph>
bool | stronglyConnected (const Digraph &digraph)
| Check whether a directed graph is strongly connected.
template<typename Digraph>
int | countStronglyConnectedComponents (const Digraph &digraph)
| Count the number of strongly connected components of a directed graph.
template<typename Digraph, typename NodeMap>
int | stronglyConnectedComponents (const Digraph &digraph, NodeMap &compMap)
| Find the strongly connected components of a directed graph.
template<typename Digraph, typename ArcMap>
int | stronglyConnectedCutArcs (const Digraph &digraph, ArcMap &cutMap)
| Find the cut arcs of the strongly connected components.
template<typename Graph>
bool | biNodeConnected (const Graph &graph)
| Check whether an undirected graph is bi-node-connected.
template<typename Graph>
int | countBiNodeConnectedComponents (const Graph &graph)
| Count the number of bi-node-connected components of an undirected graph.
template<typename Graph, typename EdgeMap>
int | biNodeConnectedComponents (const Graph &graph, EdgeMap &compMap)
| Find the bi-node-connected components of an undirected graph.
template<typename Graph, typename NodeMap>
int | biNodeConnectedCutNodes (const Graph &graph, NodeMap &cutMap)
| Find the bi-node-connected cut nodes in an undirected graph.
template<typename Graph>
bool | biEdgeConnected (const Graph &graph)
| Check whether an undirected graph is bi-edge-connected.
template<typename Graph>
int | countBiEdgeConnectedComponents (const Graph &graph)
| Count the number of bi-edge-connected components of an undirected graph.
template<typename Graph, typename NodeMap>
int | biEdgeConnectedComponents (const Graph &graph, NodeMap &compMap)
| Find the bi-edge-connected components of an undirected graph.
template<typename Graph, typename EdgeMap>
int | biEdgeConnectedCutEdges (const Graph &graph, EdgeMap &cutMap)
| Find the bi-edge-connected cut edges in an undirected graph.
template<typename Digraph>
bool | dag (const Digraph &digraph)
| Check whether a digraph is DAG.
template<typename Digraph, typename NodeMap>
void | topologicalSort (const Digraph &digraph, NodeMap &order)
| Sort the nodes of a DAG into topolgical order.
template<typename Digraph, typename NodeMap>
bool | checkedTopologicalSort (const Digraph &digraph, NodeMap &order)
| Sort the nodes of a DAG into topolgical order.
template<typename Graph>
bool | acyclic (const Graph &graph)
| Check whether an undirected graph is acyclic.
template<typename Graph>
bool | tree (const Graph &graph)
| Check whether an undirected graph is tree.
template<typename Graph>
bool | bipartite (const Graph &graph)
| Check whether an undirected graph is bipartite.
template<typename Graph, typename NodeMap>
bool | bipartitePartitions (const Graph &graph, NodeMap &partMap)
| Find the bipartite partitions of an undirected graph.
template<typename Graph>
bool | loopFree (const Graph &graph)
| Check whether the given graph contains no loop arcs/edges.
template<typename Graph>
bool | parallelFree (const Graph &graph)
| Check whether the given graph contains no parallel arcs/edges.
template<typename Graph>
bool | simpleGraph (const Graph &graph)
| Check whether the given graph is simple.
template<typename GR>
bool | eulerian (const GR &g)
| Check if the given graph is Eulerian.

## Function Documentation

## connected()

template<typename Graph>

bool connected | ( | const Graph & | graph | ) |

This function checks whether the given undirected graph is connected, i.e. there is a path between any two nodes in the graph.

Returns
  `true` if the graph is connected.

Note
  By definition, the empty graph is connected.

See also
  countConnectedComponents(), connectedComponents()
  stronglyConnected()

## countConnectedComponents()

template<typename Graph>

int countConnectedComponents | ( | const Graph & | graph | ) |

This function counts the number of connected components of the given undirected graph.

The connected components are the classes of an equivalence relation on the nodes of an undirected graph. Two nodes are in the same class if they are connected with a path.

Returns
  The number of connected components.

Note
  By definition, the empty graph consists of zero connected components.

See also
  connected(), connectedComponents()

## connectedComponents()

template<class Graph, class NodeMap>

int connectedComponents | ( | const Graph & | graph,
|  | NodeMap & | compMap )

This function finds the connected components of the given undirected graph.

The connected components are the classes of an equivalence relation on the nodes of an undirected graph. Two nodes are in the same class if they are connected with a path.

Parameters

  graph | The undirected graph.

Return values

  compMap | A writable node map. The values will be set from 0 to the number of the connected components minus one. Each value of the map will be set exactly once, and the values of a certain component will be set continuously.

Returns
  The number of connected components.

Note
  By definition, the empty graph consists of zero connected components.

See also
  connected(), countConnectedComponents()

## stronglyConnected()

template<typename Digraph>

bool stronglyConnected | ( | const Digraph & | digraph | ) |

This function checks whether the given directed graph is strongly connected, i.e. any two nodes of the digraph are connected with directed paths in both direction.

Returns
  `true` if the digraph is strongly connected.

Note
  By definition, the empty digraph is strongly connected.

See also
  countStronglyConnectedComponents(), stronglyConnectedComponents()
  connected()

## countStronglyConnectedComponents()

template<typename Digraph>

int countStronglyConnectedComponents | ( | const Digraph & | digraph | ) |

This function counts the number of strongly connected components of the given directed graph.

The strongly connected components are the classes of an equivalence relation on the nodes of a digraph. Two nodes are in the same class if they are connected with directed paths in both direction.

Returns
  The number of strongly connected components.

Note
  By definition, the empty digraph has zero strongly connected components.

See also
  stronglyConnected(), stronglyConnectedComponents()

## stronglyConnectedComponents()

template<typename Digraph, typename NodeMap>

int stronglyConnectedComponents | ( | const Digraph & | digraph,
|  | NodeMap & | compMap )

This function finds the strongly connected components of the given directed graph. In addition, the numbering of the components will satisfy that there is no arc going from a higher numbered component to a lower one (i.e. it provides a topological order of the components).

The strongly connected components are the classes of an equivalence relation on the nodes of a digraph. Two nodes are in the same class if they are connected with directed paths in both direction.

Parameters

  digraph | The digraph.

Return values

  compMap | A writable node map. The values will be set from 0 to the number of the strongly connected components minus one. Each value of the map will be set exactly once, and the values of a certain component will be set continuously.

Returns
  The number of strongly connected components.

Note
  By definition, the empty digraph has zero strongly connected components.

See also
  stronglyConnected(), countStronglyConnectedComponents()

## stronglyConnectedCutArcs()

template<typename Digraph, typename ArcMap>

int stronglyConnectedCutArcs | ( | const Digraph & | digraph,
|  | ArcMap & | cutMap )

This function finds the cut arcs of the strongly connected components of the given digraph.

The strongly connected components are the classes of an equivalence relation on the nodes of a digraph. Two nodes are in the same class if they are connected with directed paths in both direction. The strongly connected components are separated by the cut arcs.

Parameters

  digraph | The digraph.

Return values

  cutMap | A writable arc map. The values will be set to `true` for the cut arcs (exactly once for each cut arc), and will not be changed for other arcs.

Returns
  The number of cut arcs.

See also
  stronglyConnected(), stronglyConnectedComponents()

## biNodeConnected()

template<typename Graph>

bool biNodeConnected | ( | const Graph & | graph | ) |

This function checks whether the given undirected graph is bi-node-connected, i.e. a connected graph without articulation node.

Returns
  `true` if the graph bi-node-connected.

Note
  By definition,
  - a graph consisting of zero or one node is bi-node-connected,
  - a graph consisting of two isolated nodes is not bi-node-connected and
  - a graph consisting of two nodes connected by an edge is bi-node-connected.

See also
  countBiNodeConnectedComponents(), biNodeConnectedComponents()

## countBiNodeConnectedComponents()

template<typename Graph>

int countBiNodeConnectedComponents | ( | const Graph & | graph | ) |

This function counts the number of bi-node-connected components of the given undirected graph.

The bi-node-connected components are the classes of an equivalence relation on the edges of a undirected graph. Two edges are in the same class if they are on same circle.

Returns
  The number of bi-node-connected components.

See also
  biNodeConnected(), biNodeConnectedComponents()

## biNodeConnectedComponents()

template<typename Graph, typename EdgeMap>

int biNodeConnectedComponents | ( | const Graph & | graph,
|  | EdgeMap & | compMap )

This function finds the bi-node-connected components of the given undirected graph.

The bi-node-connected components are the classes of an equivalence relation on the edges of a undirected graph. Two edges are in the same class if they are on same circle.

Parameters

  graph | The undirected graph.

Return values

  compMap | A writable edge map. The values will be set from 0 to the number of the bi-node-connected components minus one. Each value of the map will be set exactly once, and the values of a certain component will be set continuously.

Returns
  The number of bi-node-connected components.

See also
  biNodeConnected(), countBiNodeConnectedComponents()

## biNodeConnectedCutNodes()

template<typename Graph, typename NodeMap>

int biNodeConnectedCutNodes | ( | const Graph & | graph,
|  | NodeMap & | cutMap )

This function finds the bi-node-connected cut nodes in the given undirected graph.

The bi-node-connected components are the classes of an equivalence relation on the edges of a undirected graph. Two edges are in the same class if they are on same circle. The bi-node-connected components are separted by the cut nodes of the components.

Parameters

  graph | The undirected graph.

Return values

  cutMap | A writable node map. The values will be set to `true` for the nodes that separate two or more components (exactly once for each cut node), and will not be changed for other nodes.

Returns
  The number of the cut nodes.

See also
  biNodeConnected(), biNodeConnectedComponents()

## biEdgeConnected()

template<typename Graph>

bool biEdgeConnected | ( | const Graph & | graph | ) |

This function checks whether the given undirected graph is bi-edge-connected, i.e. any two nodes are connected with at least two edge-disjoint paths.

Returns
  `true` if the graph is bi-edge-connected.

Note
  By definition, the empty graph is bi-edge-connected.

See also
  countBiEdgeConnectedComponents(), biEdgeConnectedComponents()

## countBiEdgeConnectedComponents()

template<typename Graph>

int countBiEdgeConnectedComponents | ( | const Graph & | graph | ) |

This function counts the number of bi-edge-connected components of the given undirected graph.

The bi-edge-connected components are the classes of an equivalence relation on the nodes of an undirected graph. Two nodes are in the same class if they are connected with at least two edge-disjoint paths.

Returns
  The number of bi-edge-connected components.

See also
  biEdgeConnected(), biEdgeConnectedComponents()

## biEdgeConnectedComponents()

template<typename Graph, typename NodeMap>

int biEdgeConnectedComponents | ( | const Graph & | graph,
|  | NodeMap & | compMap )

This function finds the bi-edge-connected components of the given undirected graph.

The bi-edge-connected components are the classes of an equivalence relation on the nodes of an undirected graph. Two nodes are in the same class if they are connected with at least two edge-disjoint paths.

Parameters

  graph | The undirected graph.

Return values

  compMap | A writable node map. The values will be set from 0 to the number of the bi-edge-connected components minus one. Each value of the map will be set exactly once, and the values of a certain component will be set continuously.

Returns
  The number of bi-edge-connected components.

See also
  biEdgeConnected(), countBiEdgeConnectedComponents()

## biEdgeConnectedCutEdges()

template<typename Graph, typename EdgeMap>

int biEdgeConnectedCutEdges | ( | const Graph & | graph,
|  | EdgeMap & | cutMap )

This function finds the bi-edge-connected cut edges in the given undirected graph.

The bi-edge-connected components are the classes of an equivalence relation on the nodes of an undirected graph. Two nodes are in the same class if they are connected with at least two edge-disjoint paths. The bi-edge-connected components are separted by the cut edges of the components.

Parameters

  graph | The undirected graph.

Return values

  cutMap | A writable edge map. The values will be set to `true` for the cut edges (exactly once for each cut edge), and will not be changed for other edges.

Returns
  The number of cut edges.

See also
  biEdgeConnected(), biEdgeConnectedComponents()

## dag()

template<typename Digraph>

bool dag | ( | const Digraph & | digraph | ) |

This function checks whether the given digraph is DAG, i.e. Directed Acyclic Graph.

Returns
  `true` if there is no directed cycle in the digraph.

See also
  acyclic()

## topologicalSort()

template<typename Digraph, typename NodeMap>

void topologicalSort | ( | const Digraph & | digraph,
|  | NodeMap & | order )

This function sorts the nodes of the given acyclic digraph (DAG) into topolgical order.

Parameters

  digraph | The digraph, which must be DAG.

Return values

  order | A writable node map. The values will be set from 0 to the number of the nodes in the digraph minus one. Each value of the map will be set exactly once, and the values will be set descending order.

See also
  dag(), checkedTopologicalSort()

## checkedTopologicalSort()

template<typename Digraph, typename NodeMap>

bool checkedTopologicalSort | ( | const Digraph & | digraph,
|  | NodeMap & | order )

This function sorts the nodes of the given acyclic digraph (DAG) into topolgical order and also checks whether the given digraph is DAG.

Parameters

  digraph | The digraph.

Return values

  order | A readable and writable node map. The values will be set from 0 to the number of the nodes in the digraph minus one. Each value of the map will be set exactly once, and the values will be set descending order.

Returns
  `false` if the digraph is not DAG.

See also
  dag(), topologicalSort()

## acyclic()

template<typename Graph>

bool acyclic | ( | const Graph & | graph | ) |

This function checks whether the given undirected graph is acyclic.

Returns
  `true` if there is no cycle in the graph.

See also
  dag()

## tree()

template<typename Graph>

bool tree | ( | const Graph & | graph | ) |

This function checks whether the given undirected graph is tree.

Returns
  `true` if the graph is acyclic and connected.

See also
  acyclic(), connected()

## bipartite()

template<typename Graph>

bool bipartite | ( | const Graph & | graph | ) |

The function checks whether the given undirected graph is bipartite.

Returns
  `true` if the graph is bipartite.

See also
  bipartitePartitions()

## bipartitePartitions()

template<typename Graph, typename NodeMap>

bool bipartitePartitions | ( | const Graph & | graph,
|  | NodeMap & | partMap )

This function checks whether the given undirected graph is bipartite and gives back the bipartite partitions.

Parameters

  graph | The undirected graph.

Return values

  partMap | A writable node map of `bool` (or convertible) value type. The values will be set to `true` for one component and `false` for the other one.

Returns
  `true` if the graph is bipartite, `false` otherwise.

See also
  bipartite()

## loopFree()

template<typename Graph>

bool loopFree | ( | const Graph & | graph | ) |

This function returns `true` if there are no loop arcs/edges in the given graph. It works for both directed and undirected graphs.

## parallelFree()

template<typename Graph>

bool parallelFree | ( | const Graph & | graph | ) |

This function returns `true` if there are no parallel arcs/edges in the given graph. It works for both directed and undirected graphs.

## simpleGraph()

template<typename Graph>

bool simpleGraph | ( | const Graph & | graph | ) |

This function returns `true` if the given graph is simple, i.e. it contains no loop arcs/edges and no parallel arcs/edges. The function works for both directed and undirected graphs.

See also
  loopFree(), parallelFree()

## eulerian()

template<typename GR>

bool eulerian | ( | const GR & | g | ) |

This function checks if the given graph is Eulerian. It works for both directed and undirected graphs.

By definition, a digraph is called Eulerian if and only if it is connected and the number of incoming and outgoing arcs are the same for each node. Similarly, an undirected graph is called Eulerian if and only if it is connected and the number of incident edges is even for each node.

Note
  There are (di)graphs that are not Eulerian, but still have an Euler tour, since they may contain isolated nodes.

See also
  DiEulerIt, EulerIt