Bridges-Python 3.5.1
Bridges(Python API)
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Properties | List of all members
bridges.graph_adj_matrix.GraphAdjMatrix Class Reference

The GraphAdjMatrix class can be used to represent adjacency matrix based. More...

Public Member Functions

 __init__ (self)
 Constructor.
 
 get_data_structure_type (self)
 This method gets the data structure type.
 
 add_vertex (self, k, e)
 Adds a new vertex to the graph, initializes the adjacency list; user is responsible for checking if the vertex already exists.
 
 add_edge (self, src, dest, weight=None)
 Adds a new edge to the graph, adds it to the index corresponding to the source, destination vertex ids; this version of the method assumes an edge weight of 1 (unweighted graph); user is responsible for checking if the vertices already exist, else an exception is thrown.
 
 set_vertex_data (self, src, vertex_data)
 
 get_vertex_data (self, src)
 
 set_edge_data (self, src, dest, data)
 
 get_edge_data (self, src, dest)
 
 get_adjacency_matrix (self, key=None)
 Gets the adjacency matrix.
 
 get_link_visualizer (self, src, 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.
 
 get_visualizer (self, vertex)
 This is a convenience method to simplify access to the element visualizer; the method assumes the vertex name points to an existing vertice, else an exception is thrown.
 
 get_data_structure_representation (self)
 Get the JSON representation of the the data structure.
 

Protected Attributes

 _vertices
 
 _matrix
 
 _edge_data
 

Properties

 vertices = property
 

Detailed Description

The GraphAdjMatrix class can be used to represent adjacency matrix based.

graphs in BRIDGES

The GraphAdjMatrix class can be used to represent adjacency matrix based graphs in BRIDGES; it takes 2 generic parameters: (1) K, which is an orderable key value used in accessing vertices (in constant time) using a hashmap. This permits data sets that need to be accessed by keys that are strings, and (2) E, an application defined type, and used in the Edge representation. The class is simply a wrapper around the Java Hashmap class and, thus, derives all its operations from it. BRIDGES provides methods to visualize the graph and its contents.

The vertices of the graph are held in a Java hashmap, for near constant time access; this lets us use strings or integral ids for vertices. The edges are accessed by a second hashmap from each vertex, again assuring near constant access time. Each edge contains the terminating vertex id and weight, as defined by the Edge class structure.

Convenience methods are provided to add vertices and edges to the graph. Edges are retrieved by using the dual hashmap, given the vertex ids of the edge.

Author
Kalpathi Subramanian, Mihai Mehedint
See also
Example tutorial at https://bridgesuncc.github.io/tutorials/Graph_AM.html

Constructor & Destructor Documentation

◆ __init__()

bridges.graph_adj_matrix.GraphAdjMatrix.__init__ (   self)

Constructor.

Member Function Documentation

◆ add_edge()

bridges.graph_adj_matrix.GraphAdjMatrix.add_edge (   self,
  src,
  dest,
  weight = None 
)

Adds a new edge to the graph, adds it to the index corresponding to the source, destination vertex ids; this version of the method assumes an edge weight of 1 (unweighted graph); user is responsible for checking if the vertices already exist, else an exception is thrown.

Parameters
src- source vertex of edge
dest- destination vertex of edge

◆ add_vertex()

bridges.graph_adj_matrix.GraphAdjMatrix.add_vertex (   self,
  k,
  e 
)

Adds a new vertex to the graph, initializes the adjacency list; user is responsible for checking if the vertex already exists.

This method will replace the value for this key

Parameters
k- vertex key value
e- user specified data, part of the vertex data

◆ get_adjacency_matrix()

bridges.graph_adj_matrix.GraphAdjMatrix.get_adjacency_matrix (   self,
  key = None 
)

Gets the adjacency matrix.

Returns
- the graph's adjacency matrix

◆ get_data_structure_representation()

bridges.graph_adj_matrix.GraphAdjMatrix.get_data_structure_representation (   self)

Get the JSON representation of the the data structure.

◆ get_data_structure_type()

bridges.graph_adj_matrix.GraphAdjMatrix.get_data_structure_type (   self)

This method gets the data structure type.

Returns
The date structure type as a string

◆ get_edge_data()

bridges.graph_adj_matrix.GraphAdjMatrix.get_edge_data (   self,
  src,
  dest 
)

◆ get_link_visualizer()

bridges.graph_adj_matrix.GraphAdjMatrix.get_link_visualizer (   self,
  src,
  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.

◆ get_vertex_data()

bridges.graph_adj_matrix.GraphAdjMatrix.get_vertex_data (   self,
  src 
)

◆ get_visualizer()

bridges.graph_adj_matrix.GraphAdjMatrix.get_visualizer (   self,
  vertex 
)

This is a convenience method to simplify access to the element visualizer; the method assumes the vertex name points to an existing vertice, else an exception is thrown.

◆ set_edge_data()

bridges.graph_adj_matrix.GraphAdjMatrix.set_edge_data (   self,
  src,
  dest,
  data 
)

◆ set_vertex_data()

bridges.graph_adj_matrix.GraphAdjMatrix.set_vertex_data (   self,
  src,
  vertex_data 
)

Member Data Documentation

◆ _edge_data

bridges.graph_adj_matrix.GraphAdjMatrix._edge_data
protected

◆ _matrix

bridges.graph_adj_matrix.GraphAdjMatrix._matrix
protected

◆ _vertices

bridges.graph_adj_matrix.GraphAdjMatrix._vertices
protected

Property Documentation

◆ vertices

bridges.graph_adj_matrix.GraphAdjMatrix.vertices = property
static

The documentation for this class was generated from the following file: