module documentation

Undocumented

Function _construct_graph_from_adjacency Generates a graph from its adjacency matrix.
Function _construct_graph_from_weighted_adjacency Generates a graph from its weighted adjacency matrix.
def _construct_graph_from_adjacency(cls, matrix, mode='directed', loops='once'): (source)

Generates a graph from its adjacency matrix.

Parameters
clsUndocumented
matrix

the adjacency matrix. Possible types are:

  • a list of lists
  • a numpy 2D array or matrix (will be converted to list of lists)
  • a scipy.sparse matrix (will be converted to a COO matrix, but not to a dense matrix)
  • a pandas.DataFrame (column/row names must match, and will be used as vertex names).
mode

the mode to be used. Possible values are:

  • "directed" - the graph will be directed and a matrix element specifies the number of edges between two vertices.
  • "undirected" - the graph will be undirected and a matrix element specifies the number of edges between two vertices. The matrix must be symmetric.
  • "max" - undirected graph will be created and the number of edges between vertex i and j is max(A(i, j), A(j, i))
  • "min" - like "max", but with min(A(i, j), A(j, i))
  • "plus" - like "max", but with A(i, j) + A(j, i)
  • "upper" - undirected graph with the upper right triangle of the matrix (including the diagonal)
  • "lower" - undirected graph with the lower left triangle of the matrix (including the diagonal)
loopsspecifies how to handle loop edges. When False or "ignore", the diagonal of the adjacency matrix will be ignored. When True or "once", the diagonal is assumed to contain the multiplicity of the corresponding loop edge. When "twice", the diagonal is assumed to contain twice the multiplicity of the corresponding loop edge.
def _construct_graph_from_weighted_adjacency(cls, matrix, mode='directed', attr='weight', loops='once'): (source)

Generates a graph from its weighted adjacency matrix.

Only edges with a non-zero weight are created.

Parameters
clsUndocumented
matrix

the adjacency matrix. Possible types are:

  • a list of lists
  • a numpy 2D array or matrix (will be converted to list of lists)
  • a scipy.sparse matrix (will be converted to a COO matrix, but not to a dense matrix)
mode

the mode to be used. Possible values are:

  • "directed" - the graph will be directed and a matrix element specifies the weight of the corresponding edge.
  • "undirected" - the graph will be undirected and a matrix element specifies the weight of the corresponding edge. The matrix must be symmetric.
  • "max" - undirected graph will be created and the weight of the edge between vertex i and j is max(A(i, j), A(j, i))
  • "min" - like "max", but with min(A(i, j), A(j, i))
  • "plus" - like "max", but with A(i, j) + A(j, i)
  • "upper" - undirected graph with the upper right triangle of the matrix (including the diagonal)
  • "lower" - undirected graph with the lower left triangle of the matrix (including the diagonal)

These values can also be given as strings without the ADJ prefix.

attrthe name of the edge attribute that stores the edge weights.
loopsspecifies how to handle loop edges. When False or "ignore", the diagonal of the adjacency matrix will be ignored. When True or "once", the diagonal is assumed to contain the weight of the corresponding loop edge. When "twice", the diagonal is assumed to contain twice the weight of the corresponding loop edge.