Package edu.fiu.jtlex.timeml.graph
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 enum
Refers to the different possible graph types. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addEvent
(ITimeMLEvent event) Adds an event to the graph.boolean
addLink
(ITimeMLLink link) Adds the provided link to the graph.boolean
addNode
(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.boolean
Checks if this graph equals an object.getEventById
(String eventId) Gets a event by id.Returns a snapshot of all the events currently in the graph.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.getLinkTypesCount
(ITimeMLGraph graph) Gets the link count per link type.getNodeById
(String 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.int
hashCode()
Generates a hash code for the graph, based of its nodes and edges.boolean
removeEvent
(ITimeMLEvent event) Removes a provided event from the graph.boolean
removeEventById
(String eventId) Removes an event by id.boolean
removeLink
(ITimeMLLink link) Removes a provided link from the graph.boolean
removeLinkById
(int linkId) Removes a link by id.boolean
removeNode
(ITimeMLNode node) Removes a provided node from the graph.boolean
removeNodeById
(String nodeId) Removes a node by id.subGraph
(Set<ITimeMLNode> nodes, Set<ITimeMLLink> links, Set<ITimeMLEvent> events) 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
-
getEventById
Gets a event by id.- Parameters:
eventId
- The id of the event to retrieve.- Returns:
- The event with the given id, or null if no such event exists.
- 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
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
-
addEvent
Adds an event to the graph.- Parameters:
event
- The event to add- Returns:
- True if the event was added, or False if the event already exists.
- Throws:
NullPointerException
- If the node is null- Since:
- jTLEX 1.0
-
removeEvent
Removes a provided event from the graph. Removes instances it is involved with as well.- Parameters:
event
- The event to remove.- Returns:
- True if removed, false if not removed or null input.
- Throws:
NullPointerException
- if the node is null.- Since:
- jTLEX 1.0
-
removeEventById
Removes an event by id. Removes instances it is involved with as well.- Parameters:
eventId
- The id of the event to remove.- Returns:
- True if removed, false if not removed.
- 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
-
getEvents
Set<ITimeMLEvent> getEvents()Returns a snapshot of all the events currently in the graph. Modifying this set won't modify the actual graph's event set.- Returns:
- A set containing the events 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.GraphType
representing 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:
equals
in 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, Set<ITimeMLEvent> events) throws IllegalArgumentException Creates a sub graph.- Parameters:
nodes
- The set ofITimeMLNode
.links
- The set ofITimeMLLink
.events
- The set ofITimeMLEvent
.- 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
-