public class ArrayBasedAdjacencyMatrixGraph extends java.lang.Object implements ArrayBasedGraph
| Constructor and Description |
|---|
ArrayBasedAdjacencyMatrixGraph() |
ArrayBasedAdjacencyMatrixGraph(int n) |
ArrayBasedAdjacencyMatrixGraph(int[][] adjacency) |
ArrayBasedAdjacencyMatrixGraph(int[][] adjacency,
double[][] weight) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEdge(int d,
int a)
add an edge between vertices d and a
By default, the edge weight is set to 1
|
void |
addEdge(int d,
int a,
double weight)
add an edge with a given weight
|
boolean |
adjacent(int d,
int a)
test whether two vertices are adjacent in the graph
|
int |
degree(int index)
return the degree of a node
|
int[][] |
getEdges()
return the list of edges (pair of vertices)
|
double |
getWeight(int d,
int a)
return the weight of edge (d,a)
|
java.util.Collection<java.lang.Integer> |
neighbors(int index)
return the vertices adjacent to a given vertex
|
void |
removeEdge(int d,
int a)
remove an edge between vertices d and a
|
void |
setWeight(int d,
int a,
double weight)
add an edge with a given weight
|
int |
sizeVertices()
return the number of vertices of the graph
|
java.lang.String |
toString() |
public ArrayBasedAdjacencyMatrixGraph()
public ArrayBasedAdjacencyMatrixGraph(int n)
public ArrayBasedAdjacencyMatrixGraph(int[][] adjacency)
public ArrayBasedAdjacencyMatrixGraph(int[][] adjacency,
double[][] weight)
public void addEdge(int d,
int a)
addEdge in interface ArrayBasedGraphpublic void addEdge(int d,
int a,
double weight)
public void setWeight(int d,
int a,
double weight)
public void removeEdge(int d,
int a)
removeEdge in interface ArrayBasedGraphpublic boolean adjacent(int d,
int a)
adjacent in interface ArrayBasedGraphpublic double getWeight(int d,
int a)
public int sizeVertices()
sizeVertices in interface ArrayBasedGraphpublic int degree(int index)
degree in interface ArrayBasedGraphpublic java.util.Collection<java.lang.Integer> neighbors(int index)
neighbors in interface ArrayBasedGraphpublic int[][] getEdges()
getEdges in interface ArrayBasedGraphpublic java.lang.String toString()
toString in class java.lang.Object