Graph#
- class sigmaepsilon.math.graph.graph.Graph(incoming_graph_data=None, **attr)[source]#
A subclass of networkx.Graph, extending its capabilities. See the documentation of networkx for the details on how to define graphs.
Note
If networkx is not installed, the class is NoneType, but the functionality it implements is still available, you just have to manage graph creation by yourself.
Examples
A basic example with networkx:
>>> from sigmaepsilon.math.graph import Graph >>> import networkx as nx >>> grid = nx.grid_2d_graph(5, 5) # 5x5 grid >>> G = Graph(grid)
- adjacency_matrix(*args, to_csr: bool = False, **kwargs) csr_matrix[source]#
Returns the adjacency matrix of the graph.
- Parameters:
to_csr (bool, Optional) – If True, the result of networkx.adjacency_matrix is returned as a csr_matrix.
*args (Tuple, Optional) – Forwarded to networkx.adjacency_matrix
**kwargs – Forwarded to networkx.adjacency_matrix
dict – Forwarded to networkx.adjacency_matrix
Optional – Forwarded to networkx.adjacency_matrix
- Returns:
The adjacency representation of the graph.
- Return type:
NumPy array, SciPy array or csr_matrix
Examples
>>> from sigmaepsilon.math.graph import Graph >>> G = Graph([(1, 1)]) >>> A = G.adjacency_matrix() >>> print(A.todense()) [[1]]