larch.model.tree.NestingTree
larch.model.tree.NestingTree¶
- class NestingTree(*arg, root_id=0, suggested_elemental_order=(), **kwarg)[source]¶
Bases:
networkx.classes.digraph.DiGraph
- __init__(*arg, root_id=0, suggested_elemental_order=(), **kwarg)[source]¶
Initialize a graph with edges, name, or graph attributes.
- Parameters
incoming_graph_data (input graph (optional, default: None)) – Data to initialize graph. If None (default) an empty graph is created. The data can be an edge list, or any NetworkX graph object. If the corresponding optional Python packages are installed the data can also be a 2D NumPy array, a SciPy sparse matrix, or a PyGraphviz graph.
attr (keyword arguments, optional (default= no attributes)) – Attributes to add to graph as key=value pairs.
See also
convert
Examples
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc >>> G = nx.Graph(name="my graph") >>> e = [(1, 2), (2, 3), (3, 4)] # list of edges >>> G = nx.Graph(e)
Arbitrary graph attribute pairs (key=value) may be assigned
>>> G = nx.Graph(e, day="Friday") >>> G.graph {'day': 'Friday'}
Methods
__init__
(*arg[, root_id, ...])Initialize a graph with edges, name, or graph attributes.
add_edge
(u, v[, implied, _clear_caches])Add an edge between u and v.
add_edges_from
(ebunch_to_add, **attr)Add all the edges in ebunch_to_add.
add_node
(code, *[, children, parent, ...])Add a single node code and update node attributes.
add_nodes
(codes, *arg[, parent])add_nodes_from
(nodes_for_adding, **attr)Add multiple nodes.
add_weighted_edges_from
(ebunch_to_add[, weight])Add weighted edges in ebunch_to_add with specified weight attr
adjacency
()Returns an iterator over (node, adjacency dict) tuples for all nodes.
clear
()Remove all nodes and edges from the graph.
clear_edges
()Remove all edges from the graph without altering nodes.
copy
([as_view])Returns a copy of the graph.
edge_slot_arrays
([alpha_locator])edge_subgraph
(edges)Returns the subgraph induced by the specified edges.
elemental_descendants
(code)elemental_descendants_iter
(code)elemental_names
()elementals
get_edge_data
(u, v[, default])Returns the attribute dictionary associated with edge (u, v).
get_nodes_by_name
(name)has_edge
(u, v)Returns True if the edge (u, v) is in the graph.
has_node
(n)Returns True if the graph contains the node n.
has_predecessor
(u, v)Returns True if node u has predecessor v.
has_successor
(u, v)Returns True if node u has successor v.
is_directed
()Returns True if graph is directed, False otherwise.
is_multigraph
()Returns True if graph is a multigraph, False otherwise.
n_elementals
()n_intermediate_nests
()nbunch_iter
([nbunch])Returns an iterator over nodes contained in nbunch that are also in the graph.
neighbors
(n)Returns an iterator over successor nodes of n.
new_node
(*[, code])Add a new nesting node to this NestingTree.
node_name
(code)node_names
()node_slot_arrays
(model)nodes_with_multiple_predecessors_iter
()nodes_with_successors_iter
()number_of_edges
([u, v])Returns the number of edges between two nodes.
number_of_nodes
()Returns the number of nodes in the graph.
order
()Returns the number of nodes in the graph.
partial_figure
([including_nodes, source, n, ...])Generate a partial figure of the graph.
predecessor_slots
(code)predecessors
(n)Returns an iterator over predecessor nodes of n.
remove_edge
(u, v, *arg, **kwarg)Remove the edge between u and v.
remove_edges_from
(ebunch)Remove all edges specified in ebunch.
remove_node
(n)Remove node n.
remove_nodes_from
(nodes)Remove multiple nodes.
reverse
([copy])Returns the reverse of the graph.
size
([weight])Returns the number of edges or total of all edge weights.
standard_competitive_edge_list
standard_competitive_edge_list_2
standard_slot_map
standard_sort
stats_summarize
()subgraph
(nodes)Returns a SubGraph view of the subgraph induced on nodes.
subgraph_from
(node)successor_slots
(code)successors
(n)Returns an iterator over successor nodes of n.
suggest_elemental_order
(order)to_directed
([as_view])Returns a directed representation of the graph.
to_directed_class
()Returns the class to use for empty directed copies.
to_png
([figsize, filename])Output the graph visualization as a png.
to_undirected
([reciprocal, as_view])Returns an undirected representation of the digraph.
to_undirected_class
()Returns the class to use for empty undirected copies.
topological_sorted
topological_sorted_no_elementals
touch
()update
([edges, nodes])Update the graph using nodes/edges/graphs as input.
Attributes
adj
Graph adjacency object holding the neighbors of each node.
degree
A DegreeView for the Graph as G.degree or G.degree().
edges
An OutEdgeView of the DiGraph as G.edges or G.edges().
in_degree
An InDegreeView for (node, in_degree) or in_degree for single node.
in_edges
An InEdgeView of the Graph as G.in_edges or G.in_edges().
n_edges
name
String identifier of the graph.
nodes
A NodeView of the Graph as G.nodes or G.nodes().
out_degree
An OutDegreeView for (node, out_degree)
out_edges
An OutEdgeView of the DiGraph as G.edges or G.edges().
pred
Graph adjacency object holding the predecessors of each node.
root_id
The code for the root node.
standard_sort_names
succ
Graph adjacency object holding the successors of each node.