Package org.qubitpi.wilhelm
Class Graph
java.lang.Object
org.qubitpi.wilhelm.Graph
A JSON-serializable object representation of a knowledge graph in wilhelm-ws.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Graph
Creates a newGraph
instance with no initial nodes or links in it.getLinks()
Returns an unmodifiable view of all the links in this Graph instance.getNodes()
Returns an unmodifiable view of all the nodes in this Graph instance.getUndirectedNeighborsOf
(Node node) Returns all weakly connected neighbors of a specified node.boolean
isEmpty()
Returns whether or not thisGraph
has neither nodes noe links.@NotNull String
toString()
Returns a JSON serialization of this Graph instance.
-
Constructor Details
-
Graph
All-args constructor.- Parameters:
nodes
- The set of all nodes contained in this Graph, cannot benull
links
- The set of all links contained in this Graph, cannot benull
-
-
Method Details
-
emptyGraph
Creates a newGraph
instance with no initial nodes or links in it.- Returns:
- a new instance
-
isEmpty
public boolean isEmpty()Returns whether or not thisGraph
has neither nodes noe links.- Returns:
true
if no nodes or links exist in thisGraph
, orfalse
otherwise.
-
getUndirectedNeighborsOf
Returns all weakly connected neighbors of a specified node.If the node has no such neighrbors, this method returns an empty list
- Parameters:
node
- a node from thisGraph
- Returns:
- all nodes each of which has a link between it and the provided node.
-
merge
-
getNodes
Returns an unmodifiable view of all the nodes in this Graph instance.- Returns:
- an immutable list of nodes
-
getLinks
Returns an unmodifiable view of all the links in this Graph instance.- Returns:
- an immutable list of links
-
toString
-