public class StringLabeller extends java.lang.Object implements VertexStringer
Modifier and Type | Class and Description |
---|---|
static class |
StringLabeller.UniqueLabelException
A minor class to store exceptions from duplicate labels in the Graph.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.Object |
DEFAULT_STRING_LABELER_KEY
The key that hasLabeller() and getLabeller() use.
|
protected Graph |
graph |
protected java.util.Map |
labelToVertex |
protected java.util.Map |
vertexToLabel |
Modifier | Constructor and Description |
---|---|
protected |
StringLabeller(Graph g) |
Modifier and Type | Method and Description |
---|---|
void |
assignDefaultLabels(java.util.Set vertices,
int offset)
Assigns textual labels to every vertex passed in.
|
void |
clear()
Wipes the entire table.
|
Graph |
getGraph()
Gets the graph associated with this StringLabeller
|
java.lang.String |
getLabel(ArchetypeVertex v)
Gets the String label associated with a particular Vertex.
|
static StringLabeller |
getLabeller(Graph g)
Gets a labeller associated with this graph.
|
static StringLabeller |
getLabeller(Graph g,
java.lang.Object key)
Returns a labeller attached to a particular key in the graph.
|
Vertex |
getVertex(java.lang.String label)
Gets the Vertex from the graph associated with this label.
|
static boolean |
hasStringLabeller(Graph g)
Checks if a labeller is associated with this graph.
|
static boolean |
hasStringLabeller(Graph g,
java.lang.Object key)
Checks for a labeller attached to a particular key in the graph.
|
Vertex |
removeLabel(java.lang.String string) |
void |
setLabel(Vertex v,
java.lang.String l)
Associates a Vertex with a Label, overrwriting any previous labels on
this vertex.
|
public static final java.lang.Object DEFAULT_STRING_LABELER_KEY
protected java.util.Map labelToVertex
protected java.util.Map vertexToLabel
protected Graph graph
protected StringLabeller(Graph g)
g
- The graph to which this labeller should attach itselfpublic static StringLabeller getLabeller(Graph g)
public static boolean hasStringLabeller(Graph g)
g
- The graph to check.public static boolean hasStringLabeller(Graph g, java.lang.Object key)
g
- the Graphkey
- the UserData key to which it is attachedpublic static StringLabeller getLabeller(Graph g, java.lang.Object key)
g
- the Graphkey
- the UserData key to which it is attachedpublic Graph getGraph()
public java.lang.String getLabel(ArchetypeVertex v)
getLabel
in interface VertexStringer
v
- a Vertex inside the Graph.FatalException
- if the Vertex is not in the Graph associated with this
Labeller.public Vertex getVertex(java.lang.String label)
label
- public void setLabel(Vertex v, java.lang.String l) throws StringLabeller.UniqueLabelException
v
- a Vertex in the labeller's graphl
- a Label to be associated with this vertexFatalException
- thrown if this vertex isn't in the Labeller's graphStringLabeller.UniqueLabelException
- thrown if this label is already associated with some other
vertex.public void assignDefaultLabels(java.util.Set vertices, int offset) throws StringLabeller.UniqueLabelException
vertices
- The set of Vertices to label. All must be part of this graph.offset
- The starting value to number vertices fromStringLabeller.UniqueLabelException
- Is thrown if some other vertexc is already numbered.FatalException
- if any Vertex is not part of the Graph.public Vertex removeLabel(java.lang.String string)
string
- public void clear()