public interface Graph<N,E>
extends java.util.Set<N>
Edges may optionally be weighted, otherwise they are assigned a default weight of 1. Weights of edges may be revised.
This interface does not specify how many edges are allowed between nodes and does specify whether a node may have an edge to itself, or not. A graph which explicitly allows both these cases is called a "multi-graph", a graph which does not allow either condition is called a "simple-graph".
This interface does not restrict whether edges are directed or not. Where edges are directed, then the presence of an edge out from one node to another does not imply that the other node has a corresponding edge back. Where edges are undirected, then the presence of an edge at one node must imply the presence of a similar edge at the other node.
This interface does not allow for "hyper-graphs", where 1 edge may connect to multiple nodes, however hyper-graphs can be supported by using a node to act as hyper-edge.
Modifier and Type | Method and Description |
---|---|
boolean |
add(N node)
Add the given node to the graph, sans edges
|
void |
addObserver(java.util.Observer o) |
float |
avg_nodal_degree() |
void |
clear_all_edges()
Clear all edges from the graph.
|
int |
countObservers() |
void |
deleteObserver(java.util.Observer o) |
void |
deleteObservers() |
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 |
hasChanged() |
boolean |
is_directed() |
boolean |
is_linked(N from,
N to)
Determine if there is a link from one node to another.
|
boolean |
is_simple() |
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.
|
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.
|
java.util.Set<N> |
successors(N from) |
void |
unplugObservable()
Unplug the delivery of Observable events.
|
boolean is_directed()
boolean is_simple()
void set(N from, N to, E label)
from
- Node from which the edge originates.to
- Node to which the edges goes.label
- The user's label for this edge.void set(N from, N to, E label, int weight)
weight
- a user-specified metric or weight for the edgeset(Object, Object, Object)
boolean add(N node)
boolean remove(N from, N to, E label)
boolean remove(N from, N to)
set(Object, Object, Object)
,
add(Object)
void clear_all_edges()
int edge_outdegree(N node)
int nodal_outdegree(N node)
node
- float avg_nodal_degree()
long link_count()
int max_nodal_degree()
java.util.Set<N> successors(N from)
node
- The given node, which is to be queried.java.util.Set<Edge<N,E>> edges(N from)
node
- The given node, which is to be queried.java.util.Collection<Edge<N,E>> edges(N from, N to)
from
- Which node we want to query edges from.to
- The node to which we're looking for an edge.edges(Object)
Edge<N,E> edge(N from, N to)
from
- Which node we want to query edges from.to
- The node to which we're looking for an edge.null
otherwise.boolean is_linked(N from, N to)
Edge<N,E> edge(N from, N to, E label)
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.java.lang.Iterable<N> random_node_iterable()
java.lang.Iterable<Edge<N,E>> random_edge_iterable(N n)
void addObserver(java.util.Observer o)
Observable
int countObservers()
Observable
void deleteObserver(java.util.Observer o)
Observable
void deleteObservers()
Observable
boolean hasChanged()
Observable
void notifyObservers()
Observable
void notifyObservers(java.lang.Object arg)
Observable
void plugObservable()
void unplugObservable()