The GraphAdjList class can be used to represent adjacency list based graphs in BRIDGES.
The GraphAdjList class can be used to represent adjacency list based graphs in BRIDGES
Convenience methods are provided to add vertices and edges to the graph as well as retrieve the adjacency list of a vertex, given its id. Convenience method addVertex() is provided to add vertices to the graph, and addEdge() is provided to add edges. Edges are retrieved by using the dual hashmap, given the vertex ids of the edge. Vertices can be styled directly from the vertex element returned by getVertex(), and edges are styled from a LinkVisualizer one can access through getLinkVisualizer(). Here is a simple example:
@code
graph = GraphAdjList()
Edge add_edge(self, Union[str, Element] src, Union[str, Element] dest, str label=None, any data=None, Union[str, Color] color="blue", float thickness=1.0, float opacity=1.0)
Adds a new edge to the graph.
Definition: graph_adj_list.py:164
Element add_vertex(self, str id, str label=None, Any data=None, Union[str, Color] color="blue", float opacity=1.0, Element original=None)
Adds a new vertex to the graph.
Definition: graph_adj_list.py:134
Edge get_link_visualizer(self, Union[str, Element] src, Union[str, Element] dest)
This is a convenience method to simplify access to the link visualizer; the method assumes the vertex...
Definition: graph_adj_list.py:401
Element get_vertex(self, key)
Getter for a specific vertex in the dictionary of vertices.
Definition: graph_adj_list.py:256
Adjacency lists are singly linked lists using the BRIDGES SLelement. Iterators are provided for easy traversal of the adjacency lists. For instance,
@code
graph = GraphAdjList()
for (e : graph.out_going_edge_set_of("a"))
Graphs can have their nodes and links affected by visual attributes. Nodes can have color, size, opacity and shape and detailed in the ElementVisualizer class. Edges support attributes such as color, thickness and opacity and are detailed in the LinkVisualizer class. Element and link attributes are set using the get_visualizer() and get_link_visualizer() methods. For instance,
GraphAdjList graph = something();
@code
graph.add_vertex("baskin");
graph.add_vertex("robins");
graph.add_edge("baskin","robins");
graph.get_visualizer().set_color("cyan");
graph.get_visualizer().set_shape("square");
graph.get_link_visualizer("baskin", "robins").set_color("green");
graph.get_link_visualizer("baskin", "robins").set_opacity("0.5f");
@author Matthew Mcquaigue, Kalpathi Subramanian
@date 2018, 7/23/19, 1/5/21
\sa graph adjacency list tutorial, https://bridgesuncc.github.io/tutorials/Graph.html
There are two visualization engines available for graph. The small
graph visualization supports all attributes of vertices and edges
but is prohibitively slow on large graphs. The large graph
visualization only supports locations (actually they are mandatory)
and colors, all other attributes are ignored.
BRIDGES picks the rendering engine automatically. But it can be
forced to pick one used forceLargeVizualization() and
forceSmallVizualization
|
None | __init__ (self) |
| Constructor for a graph adj list. More...
|
|
str | get_data_structure_type (self) |
| Getter for the data structure type. More...
|
|
Element | add_vertex (self, str id, str label=None, Any data=None, Union[str, Color] color="blue", float opacity=1.0, Element original=None) |
| Adds a new vertex to the graph. More...
|
|
Edge | add_edge (self, Union[str, Element] src, Union[str, Element] dest, str label=None, any data=None, Union[str, Color] color="blue", float thickness=1.0, float opacity=1.0) |
| Adds a new edge to the graph. More...
|
|
None | set_vertex_data (self, str src, Any vertex_data) |
| Set for the data for a given vertex. More...
|
|
Any | get_vertex_data (self, str src) |
| Get the data stored as part of this vertex. More...
|
|
None | set_edge_data (self, Union[str, Element] src, Union[str, Element] dest, Any edge_data) |
| Set edge specific data for the edge. More...
|
|
dict | vertices (self) |
| Getter for the graph nodes. More...
|
|
Element | get_vertex (self, key) |
| Getter for a specific vertex in the dictionary of vertices. More...
|
|
Any | get_adjacency_list (self, vertex=None) |
| Gets the adjacency list. More...
|
|
Iterable | key_set (self) |
| Gets the keys for all the graph vertices. More...
|
|
Iterable | value_set (self) |
| Gets the values for all the graph vertices. More...
|
|
Iterable | out_going_edge_set_of (self, Any v) |
| Get the outgoing set of edges from a given vertex. More...
|
|
Any | get_edge_data (self, Union[str, Element] src, Union[str, Element] dest) |
| Get edge specific data from this edge. More...
|
|
Any | get_edge (self, Union[str, Element] src, Union[str, Element] dest) |
| Get the edge given its vertices. More...
|
|
bool | are_all_vertices_located (self) |
| Check if all vertices in the graph have a valid location. More...
|
|
def | force_large_visualization (self, bool f) |
| Force the rendering engine to use large graph visualization. More...
|
|
def | force_small_visualization (self, bool f) |
| Force the rendering engine to use small graph visualization. More...
|
|
Edge | get_link_visualizer (self, Union[str, Element] src, Union[str, Element] dest) |
| This is a convenience method to simplify access to the link visualizer; the method assumes the vertex names point to existing vertices, else an exception is thrown. More...
|
|
ElementVisualizer | get_visualizer (self, vertex) |
| This is a convenience method to simplify access to the element visualizer. More...
|
|
dict | get_data_structure_representation (self) |
| Get the data structure representation. More...
|
|
dict | get_data_structure_large_graph (self) |
| Gets the JSON of the large graph representation. More...
|
|