lcapy.schemgraph.Graph

class lcapy.schemgraph.Graph(name, nodes, debug=False)

Bases: dict

Drawing graph

Methods

__init__(name, nodes[, debug])

add(cpt, n1, n2, size, stretch)

Add cpt between nodes n1 and n2 to the graph

add_edges(cpt, gnode1, gnode2, size, stretch)

add_node(n)

add_start_nodes()

Nodes without forward edges are connected to the end node.

assign_fixed(unknown)

Assign node positions to nodes with fixed edge lengths to nodes with known positions.

assign_fixed1(gnode)

assign_longest(path, unknown)

assign_stretchy(unknown)

Use a worklist algorithm to assign nodes with unknown positions that are connected via stretchable edges to the known nodes.

assign_stretchy1(gnode, unknown)

check_positions()

dot([filename, stage, tweak_node_label])

Generate directed graph using graphviz notation

link(n1, n2)

Make nodes n1 and n2 share common gnode

longest_path(from_gnode, to_gnode)

Find longest path through DAG from from_gnode to to_gnode or to a gnode with a known position.

makepath(from_gnode)

path_to_closest_known(from_gnode[, forward])

Find path through DAG to the closest node with a known pos.

prune()

Remove redundant paths from graph.

solve([stage])

Solve graph assigning gnode positions.

suggest_edges()

Attributes

all_nodes

nodes

add(cpt, n1, n2, size, stretch)

Add cpt between nodes n1 and n2 to the graph

add_start_nodes()

Nodes without forward edges are connected to the end node. Nodes without reverse edges are connected to the start node.

assign_fixed(unknown)

Assign node positions to nodes with fixed edge lengths to nodes with known positions. Iterate until no more changes. This stage is not needed but provides a minor optimisation.

assign_stretchy(unknown)

Use a worklist algorithm to assign nodes with unknown positions that are connected via stretchable edges to the known nodes.

dot(filename=None, stage=None, tweak_node_label=True)

Generate directed graph using graphviz notation

Make nodes n1 and n2 share common gnode

longest_path(from_gnode, to_gnode)

Find longest path through DAG from from_gnode to to_gnode or to a gnode with a known position.

path_to_closest_known(from_gnode, forward=True)

Find path through DAG to the closest node with a known pos.

prune()

Remove redundant paths from graph. If there are two parallel stretchy edges, the longest is chosen.

solve(stage=None)

Solve graph assigning gnode positions.

stage 0 — do nothing stage 1 — prune redundant edges stage 2 — add start/end nodes and assign gnode positions on longest path stage 3 — assign gnode positions with fixed positions to known gnodes stage 4 — assign all gnode positions