Class GraphElement

java.lang.Object
org.jtool.graph.GraphElement
Direct Known Subclasses:
GraphEdge, GraphNode

public abstract class GraphElement extends Object
An abstract element of a graph.
  • Constructor Details

    • GraphElement

      protected GraphElement()
      Creates a new, empty object that represents an element (a node or an edge) of a graph.
  • Method Details

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • equals

      public abstract boolean equals(GraphElement elem)
      Tests if a given graph element is equal to this graph element.
      Parameters:
      elem - the graph element to be checked
      Returns:
      the true if the given graph element is equal to this graph element
    • getIdString

      public static String getIdString(long id)
      Obtains the printed identification number.
      Parameters:
      id - the identification number
      Returns:
      the printed string of the identification number
    • equals

      public static <E extends GraphElement> boolean equals(Collection<E> s1, Collection<E> s2)
      Tests if two graph element collections are equal regarded as a set.
      Type Parameters:
      E - the type of graph elements
      Parameters:
      s1 - the first collection of graph elements
      s2 - the second collection of graph elements
      Returns:
      true if the two collections are equal, otherwise false
    • difference

      public static <E extends GraphElement> Set<E> difference(Collection<E> s1, Collection<E> s2)
      Obtains a difference set of two graph element collections regarded as a set.
      Type Parameters:
      E - the type of graph elements
      Parameters:
      s1 - the first collection of graph elements
      s2 - the second collection of graph elements
      Returns:
      the set of graph elements that remain after removing the second one from the first one
    • union

      public static <E extends GraphElement> Set<E> union(Collection<E> s1, Collection<E> s2)
      Obtains a union set of two graph element collections.
      Type Parameters:
      E - the type of graph elements
      Parameters:
      s1 - the first collection of graph elements
      s2 - the second collection of graph elements
      Returns:
      the set of graph elements that are contained in either the first one or the second one
    • intersection

      public static <E extends GraphElement> Set<E> intersection(Collection<E> s1, Collection<E> s2)
      Obtains an intersection set of two graph element collections.
      Type Parameters:
      E - the type of graph elements
      Parameters:
      s1 - the first collection of graph elements
      s2 - the second collection of graph elements
      Returns:
      the collection of graph elements that are contained in both the first one and the second one
    • subsetEqual

      public static <E extends GraphElement> boolean subsetEqual(Collection<E> s1, Collection<E> s2)
      Tests if one graph element collection is contained in or equal to the other collection.
      Type Parameters:
      E - the type of graph elements
      Parameters:
      s1 - the first collection of graph elements
      s2 - the second collection of graph elements
      Returns:
      true if all graph elements of the first one are contained in the second one, otherwise false
    • subset

      public static <E extends GraphElement> boolean subset(Collection<E> s1, Collection<E> s2)
      Tests if one graph element collection is contained in and not equal to the other collection.
      Type Parameters:
      E - the type of graph elements
      Parameters:
      s1 - the first set of graph elements
      s2 - the second set of graph elements
      Returns:
      true if all graph elements of the first one are contained in the second one and the two ones are not equal, otherwise false