A directed graph that allows self-loops, but not multiple (parallel) edges.
Edge and node data is the same as for Graph. Subclass of Graph.
An empty digraph is created with
>>> G=nx.DiGraph()
DiGraph.add_node (n) | Add a single node n. |
DiGraph.add_nodes_from (nbunch) | Add nodes from nbunch. |
DiGraph.remove_node (n) | Remove node n. |
DiGraph.remove_nodes_from (nbunch) | Remove nodes specified in nbunch. |
DiGraph.add_edge (u, v[, data]) | Add an edge between u and v with optional data. |
DiGraph.add_edges_from (ebunch[, data]) | Add all the edges in ebunch. |
DiGraph.remove_edge (u, v) | Remove the edge between (u,v). |
DiGraph.remove_edges_from (ebunch) | Remove all edges specified in ebunch. |
DiGraph.add_star (nlist[, data]) | Add a star. |
DiGraph.add_path (nlist[, data]) | Add a path. |
DiGraph.add_cycle (nlist[, data]) | Add a cycle. |
DiGraph.clear () | Remove all nodes and edges. |
DiGraph.nodes () | Return a list of the nodes. |
DiGraph.nodes_iter () | Return an iterator for the nodes. |
DiGraph.__iter__ () | Iterate over the nodes. Use “for n in G”. |
DiGraph.edges ([nbunch, data]) | Return a list of edges. |
DiGraph.edges_iter ([nbunch, data]) | Return an iterator over the edges. |
DiGraph.get_edge (u, v[, default]) | Return the data associated with the edge (u,v). |
DiGraph.neighbors (n) | Return a list of the nodes connected to the node n. |
DiGraph.neighbors_iter (n) | Return an iterator over all neighbors of node n. |
DiGraph.__getitem__ (n) | Return the neighbors of node n. Use “G[n]”. |
DiGraph.successors (n) | Return a list of the nodes connected to the node n. |
DiGraph.successors_iter (n) | Return an iterator over all neighbors of node n. |
DiGraph.predecessors (n) | Return a list of predecessor nodes of n. |
DiGraph.predecessors_iter (n) | Return an iterator over predecessor nodes of n. |
DiGraph.adjacency_list () | Return an adjacency list as a Python list of lists |
DiGraph.adjacency_iter () | Return an iterator of (node, adjacency dict) tuples for all nodes. |
DiGraph.nbunch_iter ([nbunch]) | Return an iterator of nodes contained in nbunch that are also in the graph. |
DiGraph.has_node (n) | Return True if graph has node n. |
DiGraph.__contains__ (n) | Return True if n is a node, False otherwise. Use “n in G”. |
DiGraph.has_edge (u, v) | Return True if graph contains the edge (u,v), False otherwise. |
DiGraph.has_neighbor (u, v) | Return True if node u has neighbor v. |
DiGraph.nodes_with_selfloops () | Return a list of nodes with self loops. |
DiGraph.selfloop_edges ([data]) | Return a list of selfloop edges |
DiGraph.order () | Return the number of nodes. |
DiGraph.number_of_nodes () | Return the number of nodes. |
DiGraph.__len__ () | Return the number of nodes. Use “len(G)”. |
DiGraph.size ([weighted]) | Return the number of edges. |
DiGraph.number_of_edges ([u, v]) | Return the number of edges between two nodes. |
DiGraph.number_of_selfloops () | Return the number of selfloop edges (edge from a node to itself). |
DiGraph.degree ([nbunch, with_labels, ...]) | Return the degree of a node or nodes. |
DiGraph.degree_iter ([nbunch, weighted]) | Return an iterator for (node, degree). |
DiGraph.copy () | Return a copy of the graph. |
DiGraph.to_undirected () | Return an undirected representation of the digraph. |
DiGraph.subgraph (nbunch[, copy]) | Return the subgraph induced on nodes in nbunch. |
DiGraph.reverse ([copy]) | Return the reverse of the graph |