NetworkX

Table Of Contents

Previous topic

networkx.MultiDiGraph.reverse

Next topic

networkx.LabeledGraph.add_node

Quick search

Labeled Graph

Overview

class LabeledGraph(data=None, name='', weighted=True)

Adding and Removing Nodes and Edges

LabeledGraph.add_node (n[, data])
LabeledGraph.add_nodes_from (nbunch[, data])
LabeledGraph.remove_node (n)
LabeledGraph.remove_nodes_from (nbunch)
LabeledGraph.add_edge (u, v[, data]) Add an edge between u and v with optional data.
LabeledGraph.add_edges_from (ebunch[, data]) Add all the edges in ebunch.
LabeledGraph.remove_edge (u, v) Remove the edge between (u,v).
LabeledGraph.remove_edges_from (ebunch) Remove all edges specified in ebunch.
LabeledGraph.add_star (nlist[, data]) Add a star.
LabeledGraph.add_path (nlist[, data]) Add a path.
LabeledGraph.add_cycle (nlist[, data]) Add a cycle.
LabeledGraph.clear ()

Iterating over nodes and edges

LabeledGraph.nodes ([nbunch, data])
LabeledGraph.nodes_iter ([nbunch, data])
LabeledGraph.__iter__ () Iterate over the nodes. Use “for n in G”.
LabeledGraph.edges ([nbunch, data]) Return a list of edges.
LabeledGraph.edges_iter ([nbunch, data]) Return an iterator over the edges.
LabeledGraph.get_edge (u, v[, default]) Return the data associated with the edge (u,v).
LabeledGraph.neighbors (n) Return a list of the nodes connected to the node n.
LabeledGraph.neighbors_iter (n) Return an iterator over all neighbors of node n.
LabeledGraph.__getitem__ (n) Return the neighbors of node n. Use “G[n]”.
LabeledGraph.adjacency_list () Return an adjacency list as a Python list of lists
LabeledGraph.adjacency_iter () Return an iterator of (node, adjacency dict) tuples for all nodes.
LabeledGraph.nbunch_iter ([nbunch]) Return an iterator of nodes contained in nbunch that are also in the graph.

Information about graph structure

LabeledGraph.has_node (n) Return True if graph has node n.
LabeledGraph.__contains__ (n) Return True if n is a node, False otherwise. Use “n in G”.
LabeledGraph.has_edge (u, v) Return True if graph contains the edge (u,v), False otherwise.
LabeledGraph.has_neighbor (u, v) Return True if node u has neighbor v.
LabeledGraph.nodes_with_selfloops () Return a list of nodes with self loops.
LabeledGraph.selfloop_edges ([data]) Return a list of selfloop edges
LabeledGraph.order () Return the number of nodes.
LabeledGraph.number_of_nodes () Return the number of nodes.
LabeledGraph.__len__ () Return the number of nodes. Use “len(G)”.
LabeledGraph.size ([weighted]) Return the number of edges.
LabeledGraph.number_of_edges ([u, v]) Return the number of edges between two nodes.
LabeledGraph.number_of_selfloops () Return the number of selfloop edges (edge from a node to itself).
LabeledGraph.degree ([nbunch, with_labels, ...]) Return the degree of a node or nodes.
LabeledGraph.degree_iter ([nbunch, weighted]) Return an iterator for (node, degree).

Making copies and subgraphs

LabeledGraph.copy () Return a copy of the graph.
LabeledGraph.to_directed ()
LabeledGraph.subgraph (nbunch[, copy])