Class Graph

  • Direct Known Subclasses:
    AppLifeCycle

    public class Graph
    extends java.lang.Object
    Basic directed graph implementation
    • Constructor Detail

      • Graph

        public Graph()
    • Method Detail

      • addEdge

        public void addEdge​(Edge edge)
      • addEdge

        public void addEdge​(java.lang.String from,
                            java.lang.String to)
      • addNode

        public void addNode​(Node node)
      • insertNode

        public void insertNode​(Edge edge,
                               java.lang.String nodeName)
        Convenience method for insertNode(Edge, Node)
        Parameters:
        edge - the edge to split and insert a node into
        nodeName - the name of the node to insert along the edge
      • insertNode

        public void insertNode​(Edge edge,
                               Node node)
        Insert an arbitrary node on an existing edge.
        Parameters:
        edge - the edge to split and insert a node into
        node - the node to insert along the edge
      • findEdges

        public java.util.Set<Edge> findEdges​(Node node)
        Find all edges that are connected to the specific node, both as an outgoing Edge.getFrom() or incoming Edge.getTo() end point.
        Parameters:
        node - the node with potential end points
        Returns:
        the set of edges connected to the node
      • findEdgesFrom

        public java.util.Set<Edge> findEdgesFrom​(Node from)
        Find all edges that are connected Edge.getFrom() the specific node.
        Parameters:
        from - the node with potential edges from it
        Returns:
        the set of edges from the node
      • getPath

        public Path getPath​(java.lang.String nodeNameOrigin,
                            java.lang.String nodeNameDest)
        Convenience method for getPath(Node, Node)
        Parameters:
        nodeNameOrigin - the name of the node to the path origin.
        nodeNameDest - the name of the node to the path destination.
        Returns:
        the path to take
      • getPath

        public Path getPath​(Node from,
                            Node to)
        Using BFS (Breadth First Search) return the path from a any arbitrary node to any other.
        Parameters:
        from - the node from
        to - the node to
        Returns:
        the path to take or null if there is no path.
      • getEdges

        public java.util.Set<Edge> getEdges()
      • getNodeByName

        public Node getNodeByName​(java.lang.String name)
        Get the Node by Name.
        Parameters:
        name - the name to lookup
        Returns:
        the node if found or null if not found.
      • getNodes

        public java.util.Set<Node> getNodes()
      • removeEdge

        public void removeEdge​(Edge edge)
      • removeEdge

        public void removeEdge​(java.lang.String fromNodeName,
                               java.lang.String toNodeName)
      • removeNode

        public void removeNode​(Node node)
      • setEdges

        public void setEdges​(java.util.Set<Edge> edges)
      • setNodes

        public void setNodes​(java.util.Set<Node> nodes)