easygraph.functions.components.connected module#

easygraph.functions.components.connected.connected_component_of_node(G, node)[source]#

Returns the connected component that node belongs to.

Parameters:
  • G (easygraph.Graph) –

  • node (object) – The target node

Returns:

connected_component_of_node – The connected component that node belongs to.

Return type:

set

Examples

Returns the connected component of one node Jack.

>>> connected_component_of_node(G, node='Jack')
easygraph.functions.components.connected.connected_components(G)[source]#

Returns a list of connected components, each of which denotes the edges set of a connected component.

Parameters:

G (easygraph.Graph) –

Returns:

connected_components – Each element list is the edges set of a connected component.

Return type:

list of list

Examples

>>> connected_components(G)
easygraph.functions.components.connected.connected_components_directed(G)[source]#

Returns a list of connected components, each of which denotes the edges set of a connected component.

Parameters:

G (easygraph.DiGraph) –

Returns:

connected_components – Each element list is the edges set of a connected component.

Return type:

list of list

Examples

>>> connected_components(G)
easygraph.functions.components.connected.is_connected(G)[source]#

Returns whether the graph is connected or not.

Parameters:

G (easygraph.Graph or easygraph.DiGraph) –

Returns:

is_biconnectedTrue if the graph is connected.

Return type:

boolean

Examples

>>> is_connected(G)
easygraph.functions.components.connected.number_connected_components(G)[source]#

Returns the number of connected components.

Parameters:

G (easygraph.Graph) –

Returns:

number_connected_components – The number of connected components.

Return type:

int

Examples

>>> number_connected_components(G)