Bridges-Python-3.0.2  3.0.2
Bridges(PythonAPI)
Public Member Functions | List of all members
bridges.graph_adj_matrix.GraphAdjMatrix Class Reference

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 http://bridgesuncc.github.io/tutorials/Graph_AM.html

Public Member Functions

def __init__ (self)
 Constructor. More...
 
def get_data_structure_type (self)
 This method gets the data structure type. More...
 
def 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. More...
 
def 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. More...
 
def vertices (self)
 
def set_vertex_data (self, src, vertex_data)
 
def get_vertex_data (self, src)
 
def set_edge_data (self, src, dest, data)
 
def get_edge_data (self, src, dest)
 
def get_adjacency_matrix (self, key=None)
 Gets the adjacency matrix. More...
 
def 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. More...
 
def 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. More...
 
def get_data_structure_representation (self)
 Get the JSON representation of the the data structure. More...
 

Constructor & Destructor Documentation

◆ __init__()

def bridges.graph_adj_matrix.GraphAdjMatrix.__init__ (   self)

Constructor.

Member Function Documentation

◆ add_edge()

def 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()

def 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

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

◆ get_adjacency_matrix()

def 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()

def bridges.graph_adj_matrix.GraphAdjMatrix.get_data_structure_representation (   self)

Get the JSON representation of the the data structure.

◆ get_data_structure_type()

def 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()

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

◆ get_link_visualizer()

def 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()

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

◆ get_visualizer()

def 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()

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

◆ set_vertex_data()

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

◆ vertices()

def bridges.graph_adj_matrix.GraphAdjMatrix.vertices (   self)

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