Graph¶
- class understand.Graph¶
Bases:
object
Graph plugin graph object
A graph object is provided to a graph plugin’s init(graph) and draw(graph, target) functions and represents the root of a graph. Clusters are also represented as Graph objects. Use the root graph to set
default
Graphviz attributes, define and retrieve customoptions
and provide alegend
. Use any graph object (the root or clusters) to addnodes
,edges
andclusters
. You can alsoset
graphviz attributes for the graph object.Methods Summary
Return a
cache
that can be used to store, retrieve, and share data.Add a cluster subgraph to the graph.
Return the database associated with this graph.
Set graph defaults.
Add an edge between two nodes in the graph.
Return True if an abort has been requested.
Return the Legend object associated with this graph.
Add a node to the graph.
Return the Options object associated with this graph.
Set graph attribute.
Methods Documentation
- cache(id) understand.Cache ¶
Return a
cache
that can be used to store, retrieve, and share data. Caches are globally accessible and modifiable from all plugins so graph plugins would normally use this only to access built-in caches. This function may return None if caching is not available.- Return type:
- Returns:
a cache object or None
- cluster([label[, arch]]) understand.Graph ¶
Add a cluster subgraph to the graph.
- Parameters:
label (str or None) – optional, a label for the cluster
arch (understand.Arch or None) – an architecture to sync
- Return type:
- Returns:
the new cluster
- db() understand.Db ¶
Return the database associated with this graph.
- Return type:
- Returns:
the database
- default(name, value[, kinds]) None ¶
Set graph defaults.
- Parameters:
name (str) – the attribute name
value (str) – the attribute value
kinds (str or None) – optional, the kinds this applies to. Valid kinds are “graph”, “node”, and “edge”. This defaults to “graph,node,edge” when not provided, applying to all three kinds.
- Return type:
None
Reference Graphviz for available attributes.
# set the default color for nodes and graphs but not edges graph.default("color","blue","node,graph")
- edge(node1, node2[, label]) understand.Edge ¶
Add an edge between two nodes in the graph.
- Parameters:
node1 (understand.Node) – the tail (source) node of the edge
node2 (understand.Node) – the head (destination) node of the edge
label (str or None) – optional, a label for the edge
- Return type:
- Returns:
the new edge
- is_aborted() bool ¶
Return True if an abort has been requested.
- Return type:
bool
- Returns:
True if an abort has been requested
- legend() understand.Legend ¶
Return the Legend object associated with this graph.
- Return type:
- Returns:
the legend object for the graph
Defining a legend is optional. Legends are only visible in the Understand GUI and can be toggled on and off from the graph toolbar.
- node([label[, ent]]) understand.Node ¶
Add a node to the graph.
- Parameters:
label (str) – The node’s label
ent (understand.Ent or None) – an entity to sync
- Return type:
- Returns:
the new node
Providing an ent argument is equivalent to calling sync on the returned node object:
node = graph.node("label") node.sync(ent)
- options() understand.Options ¶
Return the Options object associated with this graph.
- Return type:
- Returns:
the associated options
Defined options will appear in the context menu of the graph. Retrieve the values using
lookup
. Note that graph options only supportdefine
, not any of the ui Option methods such as<understand.Options.checkbox>()
.