Interface UndirectedGraph<V>

Type Parameters:
V - Type of vertices.
All Superinterfaces:
Graph<V>, java.io.Serializable
All Known Subinterfaces:
UndirectedMultiGraph<V>, UndirectedUnweightedGraph<V>, UndirectedUnweightedMultiGraph<V>, UndirectedWeightedGraph<V>, UndirectedWeightedMultiGraph<V>
All Known Implementing Classes:
FastUndirectedUnweightedGraph, FastUndirectedUnweightedMultiGraph, FastUndirectedWeightedGraph, FastUndirectedWeightedMultiGraph, UndirectedJungGraph, UndirectedUnweightedComplementaryGraph, UndirectedWeightedComplementaryGraph

public interface UndirectedGraph<V>
extends Graph<V>
Interface for undirected graphs.
  • Method Details

    • getIncidentNodes

      default java.util.stream.Stream<V> getIncidentNodes​(V node)
      Given a node, finds all the nodes u such that the edge (u to node) is in the graph.
      Specified by:
      getIncidentNodes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream of the incident nodes.
    • getAdjacentNodes

      default java.util.stream.Stream<V> getAdjacentNodes​(V node)
      Given a node, finds all the nodes u such that the edge (node to u) is in the graph.
      Specified by:
      getAdjacentNodes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing the adjacent nodes.
    • getMutualNodes

      default java.util.stream.Stream<V> getMutualNodes​(V node)
      Given a node, finds all the nodes u such that the edges (node to u) and (u to node) are in the graph.
      Specified by:
      getMutualNodes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes which share reciprocal links.
    • getNeighbourhood

      default java.util.stream.Stream<V> getNeighbourhood​(V node, EdgeOrientation direction)
      Gets all the nodes in the neighbourhood of a node given by a direction.
      Specified by:
      getNeighbourhood in interface Graph<V>
      Parameters:
      node - The node.
      direction - The direction of the links.
      Returns:
      A stream containing the corresponding neighbourhood.
    • getIncidentEdgesCount

      default int getIncidentEdgesCount​(V node)
      Calculates the number of incident neighbours of a node.
      Specified by:
      getIncidentEdgesCount in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      the number of incident neighbours of the node if it is contained in the graph, -1 if not.
    • getAdjacentEdgesCount

      default int getAdjacentEdgesCount​(V node)
      Calculates the number of adjacent neighbours of a node.
      Specified by:
      getAdjacentEdgesCount in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      the degree of the node if it is contained in the graph, -1 if not.
    • getMutualEdgesCount

      default int getMutualEdgesCount​(V node)
      Calculates the total number of adjacent edges of a node such that there is an incident reciprocal link towards the node.
      Specified by:
      getMutualEdgesCount in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      the number of reciprocal links starting from the node.
    • getNeighbourhoodSize

      default int getNeighbourhoodSize​(V node, EdgeOrientation direction)
      Gets all the nodes in the neighbourhood of a node given by a direction.
      Specified by:
      getNeighbourhoodSize in interface Graph<V>
      Parameters:
      node - The node.
      direction - The direction of the links.
      Returns:
      A stream containing the corresponding neighbourhood.
    • getMutualNodesCount

      default int getMutualNodesCount​(V node)
      Calculates the number of nodes for which both (u to node) and (node to u) links exist in the graph.
      Specified by:
      getMutualNodesCount in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      the number nodes for which both (u to node) and (node to u) exist in the graph if node is in the graph, -1 otherwise.
    • getIncidentNodesWeights

      default java.util.stream.Stream<Weight<V,​java.lang.Double>> getIncidentNodesWeights​(V node)
      Given a node, finds all the nodes u such that the edge (u to node) is in the graph.
      Specified by:
      getIncidentNodesWeights in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream of the incident nodes.
    • getAdjacentNodesWeights

      default java.util.stream.Stream<Weight<V,​java.lang.Double>> getAdjacentNodesWeights​(V node)
      Given a node, finds all the nodes u such that the edge (node to u) is in the graph.
      Specified by:
      getAdjacentNodesWeights in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing the adjacent nodes.
    • isMutual

      default boolean isMutual​(V nodeA, V nodeB)
      Description copied from interface: Graph
      Checks if an edge in the graph is mutual (a link from A to B and a link from B to A exists).
      Specified by:
      isMutual in interface Graph<V>
      Parameters:
      nodeA - the first node.
      nodeB - the second node.
      Returns:
      true if the edge is mutual, false if not (at least one of the links is missing).
    • getNeighbourhoodWeights

      default java.util.stream.Stream<Weight<V,​java.lang.Double>> getNeighbourhoodWeights​(V node, EdgeOrientation direction)
      Gets all the nodes in the neighbourhood of a node given by a direction.
      Specified by:
      getNeighbourhoodWeights in interface Graph<V>
      Parameters:
      node - The node.
      direction - The direction of the links.
      Returns:
      A stream containing the corresponding neighbourhood.
    • degree

      default int degree​(V node)
      Description copied from interface: Graph
      Calculates the degree of a node.
      Specified by:
      degree in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      the degree of the node if it is contained in the graph, -1 otherwise.
    • isDirected

      default boolean isDirected()
      Description copied from interface: Graph
      Indicates if the graph is directed.
      Specified by:
      isDirected in interface Graph<V>
      Returns:
      true if it is, false if not.
    • getIncidentNodesTypes

      default java.util.stream.Stream<Weight<V,​java.lang.Integer>> getIncidentNodesTypes​(V node)
      Description copied from interface: Graph
      Given a node, finds the types of the edges from the nodes u such that the edge (u to node) is in the graph.
      Specified by:
      getIncidentNodesTypes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream of the incident nodes and types.
    • getAdjacentNodesTypes

      default java.util.stream.Stream<Weight<V,​java.lang.Integer>> getAdjacentNodesTypes​(V node)
      Description copied from interface: Graph
      Given a node, finds the types of the edges towards the nodes u such that the edge (node to u) is in the graph.
      Specified by:
      getAdjacentNodesTypes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing the adjacent nodes and types.
    • getMutualNodesTypes

      default java.util.stream.Stream<Weight<V,​java.lang.Integer>> getMutualNodesTypes​(V node)
      Description copied from interface: Graph
      Given a node, find the types of edges from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
      Specified by:
      getMutualNodesTypes in interface Graph<V>
      Parameters:
      node - the node.
      Returns:
      a stream containing all the nodes in the neighbourhood and types.
    • getAdjacentMutualNodesTypes

      default java.util.stream.Stream<Weight<V,​java.lang.Integer>> getAdjacentMutualNodesTypes​(V node)
      Given a node, finds the types of the edges towards the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
      Specified by:
      getAdjacentMutualNodesTypes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and types.
    • getIncidentMutualNodesTypes

      default java.util.stream.Stream<Weight<V,​java.lang.Integer>> getIncidentMutualNodesTypes​(V node)
      Given a node, finds the types of the edges from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
      Specified by:
      getIncidentMutualNodesTypes in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and types.
    • getNeighbourhoodTypes

      default java.util.stream.Stream<Weight<V,​java.lang.Integer>> getNeighbourhoodTypes​(V node, EdgeOrientation direction)
      Description copied from interface: Graph
      Gets all the types of the edges in the neighbourhood of a node given by a direction. In the mutual case, it does not work (types are categorical values), so an empty stream is returned.
      Specified by:
      getNeighbourhoodTypes in interface Graph<V>
      Parameters:
      node - The node.
      direction - The direction of the links.
      Returns:
      A stream containing the corresponding neighbourhood.
    • getNeighbourEdgesCount

      default int getNeighbourEdgesCount​(V node)
      Description copied from interface: Graph
      Calculates the total number of edges which reach a node or start from it (not necessarily equal to the degree).
      Specified by:
      getNeighbourEdgesCount in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      the degree of the node if it is contained in the graph, -1 if not.
    • degree

      default int degree​(V node, EdgeOrientation orientation)
      Description copied from interface: Graph
      Obtains the degree of a node, depending on the neighborhood selection.
      Specified by:
      degree in interface Graph<V>
      Parameters:
      node - The node whose degree we want to find.
      orientation - The neighborhood selection.
      Returns:
      the degree.
    • inDegree

      default int inDegree​(V node)
      Description copied from interface: Graph
      Calculates the in-degree of a node.
      Specified by:
      inDegree in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      the in-degree of the node if it is contained in the graph, -1 otherwise.
    • outDegree

      default int outDegree​(V node)
      Description copied from interface: Graph
      Calculates the out-degree of a node.
      Specified by:
      outDegree in interface Graph<V>
      Parameters:
      node - The node.
      Returns:
      the out-degree of the node if it is contained in the graph, -1 otherwise.
    • mutualDegree

      default int mutualDegree​(V node)
      Description copied from interface: Graph
      Calculates the "mutual" degree of a node, i.e. the number of edges between a node and other nodes such that the other nodes are also connected to the original.
      Specified by:
      mutualDegree in interface Graph<V>
      Parameters:
      node - the node.
      Returns:
      the mutual degree of the node if it is contained in the graph, -1 otherwise.