public interface Graph
Modifier and Type  Interface and Description 

static class 
Graph.Edge
Graph edge.

Modifier and Type  Method and Description 

void 
addEdge(int source,
int target)
Creates a new edge in this graph, going from the source vertex to the
target vertex, and returns the created edge.

void 
addEdge(int source,
int target,
double weight)
Creates a new edge in this graph, going from the source vertex to the
target vertex, and returns the created edge.

int[][] 
bfs()
Breadthfirst search connected components of graph.

void 
bfs(Visitor vistor)
BFS search on graph and performs some operation defined in visitor
on each vertex during traveling.

int[][] 
dfs()
Depthfirst search connected components of graph.

void 
dfs(Visitor vistor)
DFS search on graph and performs some operation defined in visitor
on each vertex during traveling.

default double[][] 
dijkstra()
Calculates the all pair shortest path by Dijkstra algorithm.

double[] 
dijkstra(int s)
Calculate the shortest path from a source to all other vertices in the
graph by Dijkstra algorithm.

int 
getDegree(int vertex)
Returns the degree of the specified vertex.

Graph.Edge 
getEdge(int source,
int target)
Returns an edge connecting source vertex to target vertex if such edge
exist in this graph.

java.util.Collection<Graph.Edge> 
getEdges()
Returns a set of the edges contained in this graph.

java.util.Collection<Graph.Edge> 
getEdges(int vertex)
Returns a set of all edges from the specified vertex.

java.util.Collection<Graph.Edge> 
getEdges(int source,
int target)
Returns a set of all edges connecting source vertex to target vertex if
such vertices exist in this graph.

int 
getIndegree(int vertex)
Returns the indegree of the specified vertex.

int 
getNumVertices()
Returns the number vertices.

int 
getOutdegree(int vertex)
Returns the outdegree of the specified vertex.

double 
getWeight(int source,
int target)
Returns the weight assigned to a given edge.

boolean 
hasEdge(int source,
int target)
Returns true if and only if this graph contains an edge going
from the source vertex to the target vertex.

void 
removeEdge(Graph.Edge edge)
Removes the specified edge from the graph.* Returns true if the
graph contained the specified edge.

void 
removeEdge(int source,
int target)
In a simple graph, removes and returns the edge going from the specified source
vertex to the specified target vertex.

void 
removeEdges(java.util.Collection<Graph.Edge> edges)
Removes a set of edges from the graph.

Graph 
setWeight(int source,
int target,
double weight)
Sets the weight assigned to a given edge.

int[] 
sortbfs()
Topological sort digraph by breadthfirst search of graph.

int[] 
sortdfs()
Reverse topological sort digraph by depthfirst search of graph.

Graph 
subgraph(int[] vertices)
Returns a subgraph containing all given vertices.

DMatrix 
toMatrix()
Returns the (dense or sparse) matrix representation of the graph.

int getNumVertices()
boolean hasEdge(int source, int target)
source
 the id of source vertex of the edge.target
 the id of target vertex of the edge.double getWeight(int source, int target)
source
 the id of source vertex of the edge.target
 the id of target vertex of the edge.Graph setWeight(int source, int target, double weight)
source
 the id of source vertex of the edge.target
 the id of target vertex of the edge.weight
 the edge weightjava.util.Collection<Graph.Edge> getEdges()
java.util.Collection<Graph.Edge> getEdges(int vertex)
vertex
 the id of vertex for which a set of touching edges is to be
returned.java.util.Collection<Graph.Edge> getEdges(int source, int target)
In undirected graphs, some of the returned edges may have their source and target vertices in the opposite order.
source
 the id of source vertex of the edge.target
 the id of target vertex of the edge.Graph.Edge getEdge(int source, int target)
null
.
In undirected graphs, the returned edge may have its source and target vertices in the opposite order.
For multigraph, the return value is illdefined.
source
 the id of source vertex of the edge.target
 the id of target vertex of the edge.void addEdge(int source, int target)
source
 the id of source vertex of the edge.target
 the id of target vertex of the edge.void addEdge(int source, int target, double weight)
source
 the id of source vertex of the edge.target
 the id of target vertex of the edge.void removeEdges(java.util.Collection<Graph.Edge> edges)
edges
 edges to be removed from this graph.void removeEdge(int source, int target)
source
 the id of source vertex of the edge.target
 the id of target vertex of the edge.void removeEdge(Graph.Edge edge)
edge
 edge to be removed from this graph, if present.int getDegree(int vertex)
vertex
 the id of vertex.int getIndegree(int vertex)
vertex
 the id of vertex.int getOutdegree(int vertex)
vertex
 the id of vertex.int[] sortdfs()
int[][] dfs()
void dfs(Visitor vistor)
vistor
 the visitor functor.int[] sortbfs()
int[][] bfs()
void bfs(Visitor vistor)
vistor
 the visitor functor.Graph subgraph(int[] vertices)
vertices
 the vertices to be included in subgraph.double[] dijkstra(int s)
s
 the source vertex.default double[][] dijkstra()
DMatrix toMatrix()