Interface ITimeMLGraph

All Superinterfaces:
Cloneable
All Known Implementing Classes:
TimeMLGraph

public interface ITimeMLGraph extends Cloneable
Abstraction of a TimeML Graph data structure
Since:
jTLEX 1.0
  • Method Details

    • addLink

      boolean addLink(ITimeMLLink link)
      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

      boolean addNode(ITimeMLNode node)
      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

      ITimeMLNode getNodeById(String nodeId)
      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

      ITimeMLLink getLinkById(int linkId)
      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

      ITimeMLEvent getEventById(String eventId)
      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

      boolean removeLink(ITimeMLLink link)
      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

      boolean removeNode(ITimeMLNode node)
      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(String 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
    • addEvent

      boolean addEvent(ITimeMLEvent event)
      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

      boolean removeEvent(ITimeMLEvent event)
      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

      boolean removeEventById(String eventId)
      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.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code.
      Since:
      jTLEX 1.0
    • equals

      boolean equals(Object o)
      Checks if this graph equals an object.
      Overrides:
      equals in class Object
      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

      Creates a sub graph.
      Parameters:
      nodes - The set of ITimeMLNode.
      links - The set of ITimeMLLink.
      events - The set of ITimeMLEvent.
      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

      static Map<Class<?>,Integer> getLinkTypesCount(ITimeMLGraph graph)
      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