- java.lang.Object
-
- org.logicng.graphs.datastructures.Graph<T>
-
- Type Parameters:
T- the element type of the graph's nodes
public final class Graph<T> extends Object
A generic graph. Two graphs are only equal if they really are the same object.- Since:
- 1.2
- Version:
- 2.0.0
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect(Node<T> o, Node<T> t)Adds an edge between two given nodes, which must both belong to this graph.voiddisconnect(Node<T> o, Node<T> t)Removes the edge between two given nodes.Stringname()Returns the name of the graph.Node<T>node(T content)Returns the node with a given content.Set<Node<T>>nodes()Returns all nodes of the graph.StringtoString()
-
-
-
Constructor Detail
-
Graph
public Graph()
Constructor for a new graph.
-
Graph
public Graph(String name)
Constructor for a new graph.- Parameters:
name- the name of the graph
-
-
Method Detail
-
node
public Node<T> node(T content)
Returns the node with a given content. If such a node does not exist, it is created and added to the graph.- Parameters:
content- the given node content- Returns:
- the node with the given content
-
nodes
public Set<Node<T>> nodes()
Returns all nodes of the graph.- Returns:
- a set containing all nodes of the graph
-
connect
public void connect(Node<T> o, Node<T> t)
Adds an edge between two given nodes, which must both belong to this graph. (Does nothing if the nodes are already connected)- Parameters:
o- the first given nodet- the second given node
-
disconnect
public void disconnect(Node<T> o, Node<T> t)
Removes the edge between two given nodes. (Does nothing if the nodes are not connected)- Parameters:
o- the first given nodet- the second given node
-
name
public String name()
Returns the name of the graph.- Returns:
- the name of the graph
-
-