topologic package¶
-
topologic.connected_components_generator(graph: networkx.classes.graph.Graph) → Generator[networkx.classes.graph.Graph, None, None][source]¶ Returns a Generator that will provide each component as a networkx.Graph copy
- Parameters
graph (networkx.Graph) – The networkx graph object to create a connected component generator from
- Returns
A Generator that returns a copy of the subgraph corresponding to a connected component of graph
- Return type
Generator[networkx.Graph]
-
exception
topologic.DialectException(message)[source]¶ Bases:
BaseException
-
exception
topologic.InvalidGraphError(message)[source]¶ Bases:
BaseException
-
topologic.largest_connected_component(graph: networkx.classes.graph.Graph, weakly: bool = True) → networkx.classes.graph.Graph[source]¶ Returns the largest connected component of the graph.
- Parameters
graph (networkx.Graph) – The networkx graph object to select the largest connected component from. Can be either directed or undirected.
weakly (bool) – Whether to find weakly connected components or strongly connected components for directed graphs.
- Returns
A copy of the largest connected component as an nx.Graph object
- Return type
-
topologic.number_connected_components(graph: networkx.classes.graph.Graph) → int[source]¶ Returns the number of connected components in the Graph.
This function calls the appropriate newtorkx connected components function depending on whether it is Undirected or Directed.
- Parameters
graph (networkx.Graph) – The networkx graph object to determine the number of connected components for
- Returns
number of connected components (and in the case of a directed graph, strongly connected)
- Return type
-
class
topologic.PartitionedGraph[source]¶ Bases:
tupleA PartitionedGraph combines a networkx graph object with a global community partitioning for that graph.
-
property
community_partitions¶ Alias for field number 1
-
property
graph¶ Alias for field number 0
-
property
-
topologic.diagonal_augmentation(graph: Union[networkx.classes.graph.Graph, networkx.classes.digraph.DiGraph], weight_column: str = 'weight') → networkx.classes.graph.Graph[source]¶ Replaces the diagonal of adjacency matrix of the graph with the weighted degree / number of vertices in graph. For directed graphs, the weighted in and out degree is averaged.
Modifies the provided graph in place as well as returning it.
- Param
The networkx graph which will get a replaced diagonal
- Parameters
weight_column (str) – The weight column of the edge
- Returns
The networkx Graph or DiGraph object that was modified in place.
- Return type
Union[nx.Graph, nx.DiGraph]
-
exception
topologic.UnweightedGraphError(message)[source]¶ Bases:
BaseException