public class MultiDiGraph<N,E> extends java.util.Observable implements Graph<N,E>
Graph
interface.
This implementation allows for multiple, directed edges between any nodes, including between the same node.
XXX: As SimpleDiGraph inherits from this, this class probably should not be public. We don't really want different restrictions of the Graph to be type-compatible.
Constructor and Description |
---|
MultiDiGraph() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
_remove(N from,
N to,
E label)
The core, central edge removal method.
|
protected void |
_set(N from,
N to,
int weight,
E label)
The core, central set method.
|
boolean |
add(N node)
Add the given node to the graph, sans edges
|
boolean |
addAll(java.util.Collection<? extends N> c) |
float |
avg_nodal_degree() |
void |
clear_all_edges()
Clear all edges from the graph.
|
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
int |
edge_outdegree(N node)
The out-degree for a give node.
|
Edge<N,E> |
edge(N from,
N to)
Find the first edge from a node to another node.
|
Edge<N,E> |
edge(N from,
N to,
E label)
Find the edge with the given label, from the one node to another
node, if it exists.
|
java.util.Set<Edge<N,E>> |
edges(N from) |
java.util.Collection<Edge<N,E>> |
edges(N from,
N to)
Find the edges going from one node to another node.
|
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
boolean |
is_directed() |
boolean |
is_linked(N from,
N to)
Determine if there is a link from one node to another.
|
boolean |
is_simple() |
boolean |
isEmpty() |
java.util.Iterator<N> |
iterator() |
long |
link_count() |
int |
max_nodal_degree() |
int |
nodal_outdegree(N node) |
void |
notifyObservers() |
void |
notifyObservers(java.lang.Object arg) |
void |
plugObservable()
"Plug" delivery of Observable events to observers, so that any such events
are instead queued up internally, and potentially coalesced, rather than
delivered to Observers.
|
java.lang.Iterable<Edge<N,E>> |
random_edge_iterable(N n)
Provide a random-access Iterable over the <Edge<N,E>>-edges from the
given node.
|
java.lang.Iterable<N> |
random_node_iterable()
Provide a random-access Iterable over the <N>-nodes in the graph.
|
boolean |
remove(N from,
N to)
Remove all edges that go from one node to another
|
boolean |
remove(N from,
N to,
E label)
Remove 1 specific edge, given by the label, from between two nodes.
|
boolean |
remove(java.lang.Object o) |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
retainAll(java.util.Collection<?> c) |
void |
set(N from,
N to,
E label)
Set an edge from one node to another with the given label.
|
void |
set(N from,
N to,
E label,
int weight)
Set an edge from one node to another with the given label and weight.
|
int |
size() |
java.util.Set<N> |
successors(N node) |
java.lang.Object[] |
toArray() |
<N> N[] |
toArray(N[] a) |
java.lang.String |
toString() |
void |
unplugObservable()
Unplug the delivery of Observable events.
|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, setChanged
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged
protected void _set(N from, N to, int weight, E label)
from
- The N-typed node from which to set the new edgeto
- The N-typed node to which the edge should be setweight
- The weight of the node, unweighted edges should just be
set to 1.label
- The E-typed edge label object for the graph edge.public void set(N from, N to, E label)
Graph
public void set(N from, N to, E label, int weight)
Graph
set
in interface Graph<N,E>
weight
- a user-specified metric or weight for the edgeGraph.set(Object, Object, Object)
protected boolean _remove(N from, N to, E label)
from
- The N-typed node from which the edge is to be removedto
- The N-typed node to which the edge is to be removedlabel
- The E-typed edge label object for the edge which is to be
removed. If specified, only edges matching the label
will be removed. If not specified, all edges will be removed.public boolean remove(N from, N to, E label)
Graph
public boolean remove(N from, N to)
Graph
remove
in interface Graph<N,E>
Graph.set(Object, Object, Object)
,
Graph.add(Object)
public java.util.Collection<Edge<N,E>> edges(N from, N to)
Graph
edges
in interface Graph<N,E>
from
- Which node we want to query edges from.to
- The node to which we're looking for an edge.Graph.edges(Object)
public Edge<N,E> edge(N from, N to)
Graph
public Edge<N,E> edge(N from, N to, E label)
Graph
edge
in interface Graph<N,E>
from
- Which node we want to query edges from.to
- The node to which we're looking for an edge.label
- The label of the edge we're interested in.null
otherwise.public java.util.Set<N> successors(N node)
successors
in interface Graph<N,E>
public int edge_outdegree(N node)
Graph
edge_outdegree
in interface Graph<N,E>
public int nodal_outdegree(N node)
nodal_outdegree
in interface Graph<N,E>
public float avg_nodal_degree()
avg_nodal_degree
in interface Graph<N,E>
public long link_count()
link_count
in interface Graph<N,E>
public int max_nodal_degree()
max_nodal_degree
in interface Graph<N,E>
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Iterable<N> random_node_iterable()
Graph
random_node_iterable
in interface Graph<N,E>
public java.lang.Iterable<Edge<N,E>> random_edge_iterable(N n)
Graph
random_edge_iterable
in interface Graph<N,E>
public boolean add(N node)
Graph
public boolean addAll(java.util.Collection<? extends N> c)
public void clear()
public boolean contains(java.lang.Object o)
public boolean containsAll(java.util.Collection<?> c)
public boolean equals(java.lang.Object o)
public int hashCode()
public boolean isEmpty()
public int size()
public java.lang.Object[] toArray()
public <N> N[] toArray(N[] a)
public java.util.Iterator<N> iterator()
public void clear_all_edges()
Graph
clear_all_edges
in interface Graph<N,E>
public boolean remove(java.lang.Object o)
public boolean removeAll(java.util.Collection<?> c)
public boolean retainAll(java.util.Collection<?> c)
public void plugObservable()
Graph
plugObservable
in interface Graph<N,E>
public void unplugObservable()
Graph
unplugObservable
in interface Graph<N,E>
public void notifyObservers()
notifyObservers
in interface Graph<N,E>
notifyObservers
in class java.util.Observable
Observable
public void notifyObservers(java.lang.Object arg)
notifyObservers
in interface Graph<N,E>
notifyObservers
in class java.util.Observable
Observable
public boolean is_directed()
is_directed
in interface Graph<N,E>
public boolean is_simple()