dag.visualization

client.dag.visualization

Functions

Name Description
build_graph_node_details :param nodes: List of nodes to get status of
build_visualization_positions Builds the positional spacing of all nodes(markers) based on either pydot
hierarchy_pos Taken from https://epidemicsonnetworks.readthedocs.io/en/latest/_modules/EoN/auxiliary.html#hierarchy_pos
update_plotly_graph Update a graph based on based node status and figure
update_tiledb_graph Update a tiledb plot widge graph

build_graph_node_details

client.dag.visualization.build_graph_node_details(nodes)

:param nodes: List of nodes to get status of :return: tuple of node_colors and node_text

build_visualization_positions

client.dag.visualization.build_visualization_positions(network)

Builds the positional spacing of all nodes(markers) based on either pydot if available or falling back to a python computation :param network: :return: position array

hierarchy_pos

client.dag.visualization.hierarchy_pos(
    G,
    root=None,
    width=1.0,
    vert_gap=0.2,
    vert_loc=0,
    leaf_vs_root_factor=0.5,
)

Taken from https://epidemicsonnetworks.readthedocs.io/en/latest/_modules/EoN/auxiliary.html#hierarchy_pos Licensed under MIT: https://epidemicsonnetworks.readthedocs.io/en/latest/_downloads/8e9c8138fef49ddba8102fa7799c29d7/license.txt

If the graph is a tree this will return the positions to plot this in a hierarchical layout.

Based on Joel’s answer at https://stackoverflow.com/a/29597209/2966723, but with some modifications.

We include this because it may be useful for plotting transmission trees, and there is currently no networkx equivalent (though it may be coming soon).

There are two basic approaches we think of to allocate the horizontal location of a node.

  • Top down: we allocate horizontal space to a node. Then its k descendants split up that horizontal space equally. This tends to result in overlapping nodes when some have many descendants.
  • Bottom up: we allocate horizontal space to each leaf node. A node at a higher level gets the entire space allocated to its descendant leaves. Based on this, leaf nodes at higher levels get the same space as leaf nodes very deep in the tree.

We use use both of these approaches simultaneously with leaf_vs_root_factor determining how much of the horizontal space is based on the bottom up or top down approaches. 0 gives pure bottom up, while 1 gives pure top down.

:Arguments:

G the graph (must be a tree)

root the root node of the tree - if the tree is directed and this is not given, the root will be found and used - if the tree is directed and this is given, then the positions will be just for the descendants of this node. - if the tree is undirected and not given, then a random choice will be used.

width horizontal space allocated for this branch - avoids overlap with other branches

vert_gap gap between levels of hierarchy

vert_loc vertical location of root

leaf_vs_root_factor

xcenter: horizontal location of root

update_plotly_graph

client.dag.visualization.update_plotly_graph(nodes, fig=None)

Update a graph based on based node status and figure :param nodes: list of notes to update :param fig: :return:

update_tiledb_graph

client.dag.visualization.update_tiledb_graph(
    nodes,
    edges,
    node_details,
    positions,
    fig,
)

Update a tiledb plot widge graph :param nodes: nodes of graph :param edges: edges for graph :param node_details: Node details :param positions: positions for graph :param fig: figure :return: