|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectCITS2200.Graph
public class Graph
Graph.java is a class to assist with graph and network algorithms for CITS3210. It is assumed that the edges of the graph have only positive integer weights (of value 1 if the graph is not weighted).
| Method Summary | |
|---|---|
int[][] |
getEdgeMatrix()
|
int |
getNumberOfVertices()
|
int |
getWeight(int u,
int v)
|
boolean |
isDirected()
|
boolean |
isWeighted()
|
static Graph |
randomBipartiteGraph(int numberOfVertices,
boolean directed,
double density)
Creates a random unweighted bipartite graph |
static Graph |
randomGraph(int numberOfVertices,
boolean directed,
double density)
Creates a random unweighted graph |
static Graph |
randomGraph(int numberOfVertices,
double density)
Creates a random unweighted, undirected graph |
static Graph |
randomWeightedBipartiteGraph(int numberOfVertices,
boolean directed,
double density,
int maxWeight)
Creates a random weighted bipartite graph. |
static Graph |
randomWeightedGraph(int numberOfVertices,
boolean directed,
double density,
int maxWeight)
Creates a random weighted graph. |
static Graph |
readFile(String filename,
boolean weighted,
boolean directed)
reads an adjacency matrix from a file and returns it. |
String |
toString()
This method produces a representation of the graph that corresponds to the adjacency matrix used by the readFile method. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public int getWeight(int u,
int v)
u - the start of the edgev - the end of the edge
public int getNumberOfVertices()
public boolean isDirected()
public boolean isWeighted()
public int[][] getEdgeMatrix()
public static Graph randomGraph(int numberOfVertices,
boolean directed,
double density)
numberOfVertices - the nukmber of verticesdirected - true if the graph is to be directeddensity - between 0 and 1, the probablity of an edge existing.
public static Graph randomGraph(int numberOfVertices,
double density)
numberOfVertices - the nukmber of verticesdensity - between 0 and 1, the probablity of an edge existing.
public static Graph randomWeightedGraph(int numberOfVertices,
boolean directed,
double density,
int maxWeight)
numberOfVertices - the nuxkmber of verticesdirected - true if the graph is to be directedmaxWeight - the maximum edgeWeight for the Graph.density - between 0 and 1, the probablity of an edge existing.
public static Graph randomWeightedBipartiteGraph(int numberOfVertices,
boolean directed,
double density,
int maxWeight)
numberOfVertices - the nuxkmber of verticesdirected - true if the graph is to be directedmaxWeight - the maximum edgeWeight for the Graph.density - between 0 and 1, the probablity of an edge existing.
public static Graph randomBipartiteGraph(int numberOfVertices,
boolean directed,
double density)
numberOfVertices - the nukmber of verticesdirected - true if the graph is to be directeddensity - between 0 and 1, the probablity of an edge existing.
public static Graph readFile(String filename,
boolean weighted,
boolean directed)
throws Exception
filename - the name of the file to be readweighted - true if the Graph is to be weighteddirected - true if the graph is to be directed
Exceptionpublic String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||