public class Graph extends Object
| Modifier and Type | Field and Description |
|---|---|
protected List<List<VertexCell>> |
_adjacencyLists |
protected List<Vertex> |
_vertices |
| Constructor and Description |
|---|
Graph()
The method constructs am empty graph
|
Graph(List<Vertex> vertices)
The method constructs
|
Graph(List<Vertex> vertices,
List<List<VertexCell>> adjLsts) |
Graph(List<Vertex> vertices,
List<VertexCell>... adjLst)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAdjacencyList(List<VertexCell> adjLst)
The method adds an adjacency list
|
void |
addEdge(int sourceId,
int sinkId)
The method adds one edge to the graph
|
void |
addListOfVertices(List<Vertex> vrts)
The method updates the list of vertices of the graph
|
double |
BallCut(Vertex x,
double rad,
double delta) |
boolean |
BellmanFord(Vertex sourceID,
int idx)
The method implements the Bellman-Ford graph search algorithm (the complexity is O(V*E) )
|
void |
BFS(Vertex s)
The method implements the Breadth-First-Search in the graph given the source vertex
|
Graph |
buildResidualNetwork()
The method builds the residual network for this graph
|
double |
computeCost(List<Edge> edges)
The method computes the cost of a set of edges i.e.
|
double |
ConeCut(Vertex center,
double lambda,
double lambda1,
List<Vertex> S) |
List<List<Vertex>> |
coneDecomp(List<Vertex> S,
double delta,
List<Vertex> coneVertices)
The method implements the cone decomposition of the graph.
|
void |
constructFlowTables(int numberOfFlows)
The method constructs flow tables from a solution of MCF problem.
|
void |
Dijkstra(Vertex source,
int idx) |
Set<Set<Vertex>> |
findAllPaths(Vertex source,
Vertex destination)
The method implements the dfs algorithm to find all paths between two vertices.
|
void |
FordFulkerson(Vertex s,
Vertex t)
The method implements Ford-Fulkerson maximum flow search method given the source vertex and the sink vertex
|
List<List<VertexCell>> |
getAdjacencyLists()
The method returns adjacency lists of the graph
|
Graph |
getBall(Vertex center,
double radius,
boolean recompute)
The method returns a subgraph induced by a subset of vertices that are at most
at distance=radius from the center vertex
|
List<Vertex> |
getBallShell(Vertex center,
double radius,
boolean recompute)
The method returns a ball shell of a graph with a center in 'center' and with the given radius
|
List<Edge> |
getBoundary(List<Vertex> vertices) |
List<Vertex> |
getCone(Vertex center,
double radius,
List<Vertex> S)
The method returns the cone with a vertex in 'center' and a given radius in respect to the set
of vertices S
|
List<Edge> |
getEdges() |
double[][][] |
getFlowTables()
The method returns flow tables obtained after MCF
|
long |
getInputDegree(int vertexId)
The method returns the input degree of a given vertex
|
int |
getNumberOfEdges()
The method returns the number of edges of the graph
|
int |
getOutputDegree(int vertexId)
The method returns the output degree of a given vertex
|
List<VertexCell> |
getPath(Vertex v,
Vertex u)
The method returns a path between two vertices i.e.
|
double |
getRadius(Vertex v,
boolean recompute)
The method returns the radius of the graph i.e.
|
int |
getVertexPredecessor(int vertexID) |
List<Vertex> |
getVertices()
The method returns the list of vertices of the graph
|
Graph |
induceGraph(List<Vertex> vertices)
The method returns the graph induced from the current one by a set of vertices
Complexity O(n*m) because of adjacency lists.
|
boolean |
isAdjacent(Vertex u,
Vertex v)
The method returns true if there is an edge from the vertex U to the vertex V and false otherwise
|
List<Graph> |
lowStretchTree(Vertex center,
double betta,
List<Edge> bridges)
The method generate a Low Stretch Spanning Tree for the graph
|
void |
removeEdge(int vertexId,
int edgeIdx)
The method removes one edge from the graph
|
List<List<Vertex>> |
starDecomp(Vertex x0,
double delta,
double epsilon,
List<Vertex> y,
List<Vertex> coneVertices)
The method returns the Star-decomposition of the graph
|
String |
toString()
(non-Javadoc)
|
protected List<List<VertexCell>> _adjacencyLists
public Graph(List<Vertex> vertices, List<VertexCell>... adjLst)
vertices - - a list of vertices of the graphadjLst - - a set of adjacency lists. The 1st list should correspond to the vertex with id=1,
the 2nd list - to the vertex with id=2, etc...public Graph(List<Vertex> vertices, List<List<VertexCell>> adjLsts)
vertices - - a list of verticesadjLsts - - a set of adjacency lists. The 1st list should correspond to the vertex with id=1,
the 2nd list - to the vertex with id=2, etc...public Graph(List<Vertex> vertices)
vertices - - a list of verticespublic Graph()
public int getNumberOfEdges()
public List<Vertex> getVertices()
public List<List<VertexCell>> getAdjacencyLists()
public void addListOfVertices(List<Vertex> vrts)
vrts - new list of vertices of the graphpublic void addAdjacencyList(List<VertexCell> adjLst)
adjLst - - a new adjacency listpublic String toString()
toString in class ObjectObject.toString()public int getOutputDegree(int vertexId)
vertexId - - the id of the vertex for which the output degree should be computedpublic long getInputDegree(int vertexId)
vertexId - - the id of the vertex for which the input degree should be computedpublic int getVertexPredecessor(int vertexID)
vertexID - the id of a vertexpublic List<VertexCell> getPath(Vertex v, Vertex u)
v - - the first vertex in the pathu - - the last vertex of the pathpublic double[][][] getFlowTables()
public double getRadius(Vertex v, boolean recompute)
public Graph getBall(Vertex center, double radius, boolean recompute)
center - - the center vertex of the ballradius - - the radius of the ballrecompute - - the boolean value indicating if it is necessary to recompute shortest paths estimationspublic List<Vertex> getBallShell(Vertex center, double radius, boolean recompute)
center - - the center of the corresponding ballradius - - radius of the ballrecompute - - a boolean value indicating if it is needed to recompute the shortest path estimationspublic List<Vertex> getCone(Vertex center, double radius, List<Vertex> S)
center - - the vertex of the coneradius - - the radius ot the cone (i.e. max distance)S - - the set in respect to which the cone should be definedpublic double computeCost(List<Edge> edges)
edges - - a list of edges for which the cost should be computedpublic double BallCut(Vertex x, double rad, double delta)
public List<List<Vertex>> coneDecomp(List<Vertex> S, double delta, List<Vertex> coneVertices)
S - - the list of cone verticesdelta - - delta parameter of the algorithmconeVertices - - a list of cone vertices (used as an additional output parameter of the method)public List<List<Vertex>> starDecomp(Vertex x0, double delta, double epsilon, List<Vertex> y, List<Vertex> coneVertices)
x0 - - the center of the stardelta - - delta parameter of the algorithm ( =0.333)epsilon - - epsilon parameter of the algorithm (precision)y - - a list of vertices within the center-ball of the star that are the closest ones to the cone vertices (used as an additional return value)public Graph induceGraph(List<Vertex> vertices)
vertices - - the list of vertices that should be present in the induced graph (NOTE: the vertices objects should belong to THIS object
as they refer to the adjacency lists of THIS graph)public List<Graph> lowStretchTree(Vertex center, double betta, List<Edge> bridges)
center - - the center (the root) of the treebetta - - betta parameter for the algorithmbridges - - edges x(i)-y(i) that are the bridges between different cones and ballspublic boolean isAdjacent(Vertex u, Vertex v)
u - - id of the 1st vertexv - - id of the 2nd vertexpublic void BFS(Vertex s)
s - - the source vertex in the graphpublic void FordFulkerson(Vertex s, Vertex t)
s - - the source vertext - - the sink vertexpublic boolean BellmanFord(Vertex sourceID, int idx)
sourceID - - the id of the source vertexpublic void Dijkstra(Vertex source, int idx)
public Set<Set<Vertex>> findAllPaths(Vertex source, Vertex destination)
public Graph buildResidualNetwork()
public void removeEdge(int vertexId,
int edgeIdx)
vertexId - - an ide of a source vertex of the edgeedgeIdx - - an index of the edge to be removedpublic void addEdge(int sourceId,
int sinkId)
sourceId - - an id of a source vertex of the edgesinkId - - an index of the edge to be removedpublic void constructFlowTables(int numberOfFlows)
numberOfFlows - - the number of flows in the graphCopyright © 2017. All rights reserved.