Class Edge

  • All Implemented Interfaces:
    Serializable, EdgeId, ElementId
    Direct Known Subclasses:
    LazyEdge

    public class Edge
    extends Element
    implements EdgeId
    An Edge in an Element containing a source, destination and a directed flag. The source and destination vertices can be any type of Object. There is no requirement for these vertices to connect to an Entity vertex - for example you could have a 'graph' of just edges. Edges are designed so that multiple edges can share the same identifiers but are distinguished via their group.
    See Also:
    Edge.Builder, Serialized Form
    • Constructor Detail

      • Edge

        public Edge​(String group)
      • Edge

        public Edge​(String group,
                    Object source,
                    Object destination,
                    boolean directed)
        Constructs an instance of Edge.

        If the edge is undirected the the source and destination vertices may get swapped to ensure undirected edges are consistently constructed.

        Parameters:
        group - the Edge group
        source - the source vertex
        destination - the destination vertex
        directed - true if the edge is directed
      • Edge

        public Edge​(String group,
                    Object source,
                    Object destination,
                    boolean directed,
                    EdgeId.MatchedVertex matchedVertex,
                    Properties properties)
        Constructs an instance of Edge.

        If the edge is undirected the the source and destination vertices may get swapped to ensure undirected edges are consistently constructed.

        Parameters:
        group - the Edge group
        source - the source vertex
        destination - the destination vertex
        directed - true if the edge is directed
        matchedVertex - used at query time to mark which vertex was matched.
        properties - the edge properties
    • Method Detail

      • getSource

        public Object getSource()
        Description copied from interface: EdgeId
        Get the source vertex.
        Specified by:
        getSource in interface EdgeId
        Returns:
        the object at the edge source
      • getDestination

        public Object getDestination()
        Description copied from interface: EdgeId
        Get the destination vertex.
        Specified by:
        getDestination in interface EdgeId
        Returns:
        the object at the edge destination
      • getDirectedType

        public DirectedType getDirectedType()
        Description copied from interface: EdgeId
        Get the directionality of the current edge.
        Specified by:
        getDirectedType in interface EdgeId
        Returns:
        the directed type
      • isDirected

        public boolean isDirected()
        Specified by:
        isDirected in interface EdgeId
        Returns:
        true if directed is DIRECTED, EITHER or null. Otherwise false.
      • getMatchedVertex

        public EdgeId.MatchedVertex getMatchedVertex()
        Description copied from interface: EdgeId
        Get the vertex which is to be reported if a matched vertex is requested.
        Specified by:
        getMatchedVertex in interface EdgeId
        Returns:
        the matched vertex
      • setIdentifiers

        public void setIdentifiers​(Object source,
                                   Object destination,
                                   DirectedType directedType)
        Sets the identifiers for an Edge.

        If the edge is undirected the the source and destination vertices may get swapped to ensure undirected edges are consistently constructed.

        Specified by:
        setIdentifiers in interface EdgeId
        Parameters:
        source - the source vertex
        destination - the destination vertex
        directedType - the edge directedType
      • setIdentifiers

        public void setIdentifiers​(Object source,
                                   Object destination,
                                   boolean directed)
        Sets the identifiers for an Edge.

        If the edge is undirected the the source and destination vertices may get swapped to ensure undirected edges are consistently constructed.

        Parameters:
        source - the source vertex
        destination - the destination vertex
        directed - true if the edge is directed
      • setIdentifiers

        public void setIdentifiers​(Object source,
                                   Object destination,
                                   DirectedType directedType,
                                   EdgeId.MatchedVertex matchedVertex)
        Sets the identifiers for an Edge.

        If the edge is undirected the the source and destination vertices may get swapped to ensure undirected edges are consistently constructed.

        Specified by:
        setIdentifiers in interface EdgeId
        Parameters:
        source - the source vertex
        destination - the destination vertex
        directedType - the edge directedType
        matchedVertex - the vertex that matched a query seed
      • setIdentifiers

        public void setIdentifiers​(Object source,
                                   Object destination,
                                   boolean directed,
                                   EdgeId.MatchedVertex matchedVertex)
        Sets the identifiers for an Edge.

        If the edge is undirected the the source and destination vertices may get swapped to ensure undirected edges are consistently constructed.

        Parameters:
        source - the source vertex
        destination - the destination vertex
        directed - true if the edge is directed
        matchedVertex - the vertex that matched a query seed
      • hashCode

        public int hashCode()
        Note this does not include the matchedVertex field.
        Overrides:
        hashCode in class Element
        Returns:
        a hash code value for this edge.
      • equals

        public boolean equals​(Object obj)
        Note this does not include the matchedVertex field.
        Overrides:
        equals in class Element
        Parameters:
        obj - the reference object with which to compare.
        Returns:
        true if this object is the same as the obj argument; false otherwise.
      • equals

        public boolean equals​(Edge edge)
        Note this does not include the matchedVertex field.
        Parameters:
        edge - the reference Edge with which to compare.
        Returns:
        true if this object is the same as the edge argument; false otherwise.