Package edu.fiu.jtlex.timeml.data
Interface ITimeMLGraph
- All Superinterfaces:
Cloneable
- All Known Implementing Classes:
TimeMLGraph
Abstraction of a TimeML Graph data structure
- Since:
- jTLEX 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumRefers to the different possible graph types. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddLink(ITimeMLLink link) Adds the provided link to the graph.booleanaddNode(ITimeMLNode node) Adds a node to the graph.clone()Creates a clone of the graph by first cloning the nodes and links and then returning them inside a new Graph object.booleanChecks if this graph equals an object.Gets the Graph's type.Each link has a node at its beginning and end.getLinkById(int linkId) Gets a link by id.getLinks()Returns a snapshot of all the links currently in the graph.static Map<ITimeMLLink.LinkTag,Integer> getLinkTypesCount(ITimeMLGraph graph) Gets the link count per link type.getNodeById(int nodeId) Gets a node by id.getNodes()Returns a snapshot of all the nodes currently in the graph.Each link has a node at its beginning and end.Gets the Graph's Parent Graph.inthashCode()Generates a hash code for the graph, based of its nodes and edges.booleanremoveLink(ITimeMLLink link) Removes a provided link from the graph.booleanremoveLinkById(int linkId) Removes a link by id.booleanremoveNode(ITimeMLNode node) Removes a provided node from the graph.booleanremoveNodeById(int nodeId) Removes a node by id.subGraph(Set<ITimeMLNode> nodes, Set<ITimeMLLink> links) Creates a sub graph.toJson()Returns the JSON (RFC 8259) representation of the graph.
-
Method Details
-
addLink
Adds the provided link to the graph. The endpoints of the link must already be present in the Graph.- Parameters:
link- The ILink to be added.- Returns:
- True if the link was added, otherwise it returns false if the link already exists or if the nodes were not in the graph, and as a result, the link is not added.
- Throws:
NullPointerException- if the link is null.IllegalArgumentException- if nodes are not in graph before link is added.- Since:
- jTLEX 1.0
-
addNode
Adds a node to the graph.- Parameters:
node- The node to add- Returns:
- True if the node was added, or False if the node already exists.
- Throws:
NullPointerException- if the node is null.- Since:
- jTLEX 1.0
-
getNodeById
Gets a node by id.- Parameters:
nodeId- The id of the node to retrieve.- Returns:
- The node with the given id, or null if no such node exist.
- Since:
- jTLEX 1.0
-
getLinkById
Gets a link by id.- Parameters:
linkId- The id of the link to retrieve.- Returns:
- The link with the given id, or null if no such link exist.
- Since:
- jTLEX 1.0
-
removeLink
Removes a provided link from the graph.- Parameters:
link- The ILink to remove.- Returns:
- true if removed, false if not removed or null input.
- Throws:
NullPointerException- if the ILink is null.- Since:
- jTLEX 1.0
-
removeNode
Removes a provided node from the graph. Removes links it is involved with as well.- Parameters:
node- The node to remove.- Returns:
- True if removed, false if not removed or null input.
- Throws:
NullPointerException- if the node is null.- Since:
- jTLEX 1.0
-
removeNodeById
boolean removeNodeById(int nodeId) Removes a node by id. Removes links it is involved with as well.- Parameters:
nodeId- The id of the node to remove.- Returns:
- True if removed, false if not removed.
- Since:
- jTLEX 1.0
-
removeLinkById
boolean removeLinkById(int linkId) Removes a link by id.- Parameters:
linkId- The id of the link to remove.- Returns:
- True if removed, false if not removed or null input.
- Since:
- jTLEX 1.0
-
getNodes
Set<ITimeMLNode> getNodes()Returns a snapshot of all the nodes currently in the graph. Modifying this set won't modify the actual graph's node set.- Returns:
- A set containing the nodes currently in the graph.
- Since:
- jTLEX 1.0
-
getLinks
Set<ITimeMLLink> getLinks()Returns a snapshot of all the links currently in the graph. Modifying this set won't modify the actual graph's link set.- Returns:
- A set containing the links currently in the graph.
- Since:
- jTLEX 1.0
-
getOutLinks
Map<String,Set<ITimeMLLink>> getOutLinks()Each link has a node at its beginning and end. As such, each node can have an incoming link or an outgoing link. This method is used to track each outgoing link from each node.- Returns:
- A map with all the nodes in the graph and their outgoing links.
- Since:
- jTLEX 1.0
-
getInLinks
Map<String,Set<ITimeMLLink>> getInLinks()Each link has a node at its beginning and end. As such, each node can have an incoming link or an outgoing link. This method is used to track each incoming link from each node.- Returns:
- A map with all the nodes in the graph and their incoming links.
- Since:
- jTLEX 1.0
-
getGraphType
ITimeMLGraph.GraphType getGraphType()Gets the Graph's type.- Returns:
- A
ITimeMLGraph.GraphTyperepresenting the graph type. - Since:
- jTLEX 1.0
-
getParent
ITimeMLGraph getParent()Gets the Graph's Parent Graph. Used for obtaining the parent graph from Subordination Graphs.- Returns:
- A TimeMLGraph representing the parent, or null if it is not a subordination graph, meaning there is no parent.
- Since:
- jTLEX 1.0
-
clone
ITimeMLGraph clone()Creates a clone of the graph by first cloning the nodes and links and then returning them inside a new Graph object.- Returns:
- A field-by-field copy of the graph.
- Since:
- jTLEX 1.0
-
toJson
String toJson()Returns the JSON (RFC 8259) representation of the graph.- Returns:
- A flattened JSON string of the graph.
- Since:
- jTLEX 1.0
-
hashCode
int hashCode()Generates a hash code for the graph, based of its nodes and edges. -
equals
Checks if this graph equals an object.- Overrides:
equalsin classObject- Parameters:
o- The object to compare against.- Returns:
- True if both graphs are equal, i.e. same set of nodes and links, or else false.
- Throws:
NullPointerException- If the object to compare against is false.- Since:
- jTLEX 1.0
-
subGraph
ITimeMLGraph subGraph(Set<ITimeMLNode> nodes, Set<ITimeMLLink> links) throws IllegalArgumentException Creates a sub graph.- Parameters:
nodes- The set ofITimeMLNode.links- The set ofITimeMLLink.- Returns:
- an ITimeMLGraph that is the subgraph.
- Throws:
IllegalArgumentException- if the nodes or links are not inside the graph the subgraph is being created from- Since:
- jTLEX 1.0
-
getLinkTypesCount
Gets the link count per link type.- Parameters:
graph- the TimeML Graph to count the links from.- Returns:
- A map containing the number of A-Link, S-Link, and T-Link.
- Since:
- jTLEX 1.0
-