networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturns
incidence_matrix(G, nodelist=None, edgelist=None, oriented=False, weight=None)

The incidence matrix assigns each row to a node and each column to an edge. For a standard incidence matrix a 1 appears wherever a row's node is incident on the column's edge. For an oriented incidence matrix each edge is assigned an orientation (arbitrarily for undirected and aligning to direction for directed). A -1 appears for the source (tail) of an edge and 1 for the destination (head) of the edge. The elements are zero otherwise.

Notes

For MultiGraph/MultiDiGraph, the edges in edgelist should be (u,v,key) 3-tuples.

"Networks are the best discrete model for so many problems in applied mathematics" .

Parameters

G : graph

A NetworkX graph

nodelist : list, optional (default= all nodes in G)

The rows are ordered according to the nodes in nodelist. If nodelist is None, then the ordering is produced by G.nodes().

edgelist : list, optional (default= all edges in G)

The columns are ordered according to the edges in edgelist. If edgelist is None, then the ordering is produced by G.edges().

oriented: bool, optional (default=False) :

If True, matrix elements are +1 or -1 for the head or tail node respectively of each edge. If False, +1 occurs at both nodes.

weight : string or None, optional (default=None)

The edge data key used to provide each value in the matrix. If None, then each edge has weight 1. Edge weights, if used, should be positive so that the orientation can provide the sign.

Returns

A : SciPy sparse matrix

The incidence matrix of G.

Returns incidence matrix of G.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/linalg/graphmatrix.py#9
type: <class 'function'>
Commit: