Graph.GraphType
Constructor and Description |
---|
UndirectedGraph(HashSet<T> nodes,
com.google.common.collect.ImmutableSetMultimap<T,T> adj,
HashMap<Tuple<T,T>,Double> wts)
Constructs an undirected graph
|
Modifier and Type | Method and Description |
---|---|
int |
degree(T n)
Gets the degree of a node
|
Collection<Map.Entry<T,T>> |
edges()
Gets a collection of the edges
|
Iterator<Map.Entry<T,T>> |
edgesIter()
Iterates over the edges
|
boolean |
hasEdge(T u,
T v)
Returns true if an edge exists in the graph
|
boolean |
hasNode(T n)
Returns true if the graph contains the node n
|
Collection<T> |
neighbors(T n)
Gets a collection of the neighbors of a node
|
Collection<T> |
nodes()
Gets a list of nodes in the graph
|
Iterator<T> |
nodesIter()
Gets an iterator over the nodes
|
int |
numberOfNodes()
Gets the number of nodes in the graph
|
int |
size()
Gets the number of edges in the graph
|
double |
size(boolean weighted)
Gets the sum of edges in the graph
|
public UndirectedGraph(HashSet<T> nodes, com.google.common.collect.ImmutableSetMultimap<T,T> adj, HashMap<Tuple<T,T>,Double> wts)
nodes
- Set of nodesadj
- Multimap of adjacency between nodeswts
- Hashmap of an edge (represented by a Map Entry) and weightspublic Iterator<T> nodesIter()
Graph
public Collection<T> nodes()
Graph
public int numberOfNodes()
Graph
numberOfNodes
in interface Graph<T>
public boolean hasNode(T n)
Graph
public boolean hasEdge(T u, T v)
Graph
public Collection<T> neighbors(T n)
Graph
public Collection<Map.Entry<T,T>> edges()
Graph
public Iterator<Map.Entry<T,T>> edgesIter()
Graph
public int size()
Graph
Copyright © 2018. All rights reserved.