Interface Graph<V>

Type Parameters:
V - Type of vertices.
All Superinterfaces:
java.io.Serializable
All Known Subinterfaces:
DirectedGraph<V>, DirectedMultiGraph<U>, DirectedUnweightedGraph<V>, DirectedUnweightedMultiGraph<V>, DirectedWeightedGraph<V>, DirectedWeightedMultiGraph<U>, FastGraph<U>, FastMultiGraph<U>, MultiGraph<U>, Tree<U>, UndirectedGraph<V>, UndirectedMultiGraph<V>, UndirectedUnweightedGraph<V>, UndirectedUnweightedMultiGraph<V>, UndirectedWeightedGraph<V>, UndirectedWeightedMultiGraph<V>, UnweightedGraph<V>, UnweightedMultiGraph<V>, UnweightedTree<U>, WeightedGraph<V>, WeightedMultiGraph<V>, WeightedTree<U>
All Known Implementing Classes:
AbstractFastGraph, AbstractFastMultiGraph, ComplementaryGraph, DirectedJungGraph, DirectedUnweightedComplementaryGraph, DirectedWeightedComplementaryGraph, FastDirectedUnweightedGraph, FastDirectedUnweightedMultiGraph, FastDirectedWeightedGraph, FastDirectedWeightedMultiGraph, FastTree, FastUndirectedUnweightedGraph, FastUndirectedUnweightedMultiGraph, FastUndirectedWeightedGraph, FastUndirectedWeightedMultiGraph, FastUnweightedTree, FastWeightedTree, JungGraph, UndirectedJungGraph, UndirectedUnweightedComplementaryGraph, UndirectedWeightedComplementaryGraph

public interface Graph<V>
extends java.io.Serializable
Interface for a generic graph.
  • Method Summary

    Modifier and Type Method Description
    default boolean addEdge​(V nodeA, V nodeB)
    Adds a new edge to the graph.
    default boolean addEdge​(V nodeA, V nodeB, boolean insertNodes)
    Adds an edge to the graph.
    default boolean addEdge​(V nodeA, V nodeB, double weight)
    Adds a new edge to the graph.
    default boolean addEdge​(V nodeA, V nodeB, double weight, int type)
    Adds a new edge to the graph.
    boolean addEdge​(V nodeA, V nodeB, double weight, int type, boolean insertNodes)
    Adds a weighted edge to the graph.
    default boolean addEdge​(V nodeA, V nodeB, int type)
    Adds a new edge to the graph.
    boolean addNode​(V node)
    Adds a new node to the graph.
    Graph<V> complement()
    Complements the graph
    boolean containsEdge​(V nodeA, V nodeB)
    Checks if an edge exists in the graph.
    boolean containsVertex​(V node)
    Checks if a vertex exists in the graph.
    default int degree​(V node)
    Calculates the degree of a node.
    int degree​(V node, EdgeOrientation orientation)
    Obtains the degree of a node, depending on the neighborhood selection.
    double[][] getAdjacencyMatrix​(EdgeOrientation direction)
    Gets the adjacency matrix.
    Index<V> getAdjacencyMatrixMap()
    For an adjacency matrix, obtains the mapping between indexes and nodes.
    int getAdjacentEdgesCount​(V node)
    Calculates the number of adjacent edges of a node (not necessarily equal to the out-degree).
    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.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getAdjacentMutualNodesWeights​(V node)
    Given a node, finds the weights of the edges towards the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
    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.
    default int getAdjacentNodesCount​(V node)
    Calculates the number of adjacent edges of a node (not necessarily equal to the out-degree).
    java.util.stream.Stream<Weight<V,​java.lang.Integer>> getAdjacentNodesTypes​(V node)
    Given a node, finds the types of the edges towards the nodes u such that the edge (node to u) is in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getAdjacentNodesWeights​(V node)
    Given a node, finds the weights of the edges towards the nodes u such that the edge (node to u) is in the graph.
    java.util.stream.Stream<V> getAllNodes()
    Gets all the nodes in the graph.
    long getEdgeCount()
    Measures the number of edges in the network.
    int getEdgeType​(V nodeA, V nodeB)
    Obtains the type of an edge in the graph
    double getEdgeWeight​(V nodeA, V nodeB)
    Obtains the weight of an edge in the graph
    int getIncidentEdgesCount​(V node)
    Calculates the number of incident edges of a node (not necessarily equal to the in-degree).
    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.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getIncidentMutualNodesWeights​(V node)
    Given a node, finds the weights of the edges from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
    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.
    default int getIncidentNodesCount​(V node)
    Calculates the number of incident edges of a node (not necessarily equal to the in-degree).
    java.util.stream.Stream<Weight<V,​java.lang.Integer>> getIncidentNodesTypes​(V node)
    Given a node, finds the types of the edges from the nodes u such that the edge (u to node) is in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getIncidentNodesWeights​(V node)
    Given a node, finds the weights of the edges from the nodes u such that the edge (u to node) is in the graph.
    java.util.stream.Stream<V> getIsolatedNodes()
    Obtains the set of nodes without edges.
    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.
    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.
    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.
    java.util.stream.Stream<Weight<V,​java.lang.Integer>> getMutualNodesTypes​(V node)
    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.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getMutualNodesWeights​(V node)
    Given a node, finds the weights of the edges towards and from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
    int getNeighbourEdgesCount​(V node)
    Calculates the total number of edges which reach a node or start from it (not necessarily equal to the degree).
    java.util.stream.Stream<V> getNeighbourhood​(V node, EdgeOrientation direction)
    Gets all the nodes in the neighbourhood of a node given by a direction.
    int getNeighbourhoodSize​(V node, EdgeOrientation direction)
    Gets all the nodes in the neighbourhood of a node given by a direction.
    java.util.stream.Stream<Weight<V,​java.lang.Integer>> getNeighbourhoodTypes​(V node, EdgeOrientation direction)
    Gets all the types of the edges in the neighbourhood of a node given by a direction.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getNeighbourhoodWeights​(V node, EdgeOrientation direction)
    Gets all the weights of the edges in the neighbourhood of a node given by a direction.
    java.util.stream.Stream<V> getNeighbourNodes​(V node)
    Given a node, finds all the nodes u so that either (node to u) or (u to node) are in the graph.
    default int getNeighbourNodesCount​(V node)
    Calculates the total number of edges which reach a node or start from it (not necessarily equal to the degree).
    java.util.stream.Stream<Weight<V,​java.lang.Integer>> getNeighbourNodesTypes​(V node)
    Given a node, finds the types of the edges from the nodes u such that the edge (node to u) or the edge (u to node) are in the graph.
    java.util.stream.Stream<Weight<V,​java.lang.Double>> getNeighbourNodesWeights​(V node)
    Given a node, finds the weights of the edges from the nodes u such that the edge (node to u) or the edge (u to node) are in the graph.
    java.util.stream.Stream<V> getNodesWithAdjacentNeighbors()
    Obtains the set of nodes which have adjacent edges.
    java.util.stream.Stream<V> getNodesWithIncidentNeighbors()
    Obtains the set of nodes which have incident edges.
    java.util.stream.Stream<V> getNodesWithMutualNeighbors()
    Obtains the set of nodes having mutual edges.
    java.util.stream.Stream<V> getNodesWithNeighbors()
    Obtains the set of nodes having either incident or adjacent edges.
    java.util.stream.Stream<V> getNodesWithNeighbors​(EdgeOrientation direction)
    Obtains the set of nodes with edges in a particular direction.
    long getVertexCount()
    Measures the number of nodes in the network.
    boolean hasAdjacentNeighbors​(V u)
    Checks if the user has adjacent edges or not.
    boolean hasIncidentNeighbors​(V u)
    Checks if the user has incident edges or not.
    boolean hasMutualNeighbors​(V u)
    Checks if the user has mutual edges.
    boolean hasNeighbors​(V u)
    Checks if the user shares at least an edge with other user.
    default boolean hasNeighbors​(V u, EdgeOrientation orient)
    Checks if the user has neighbors.
    int inDegree​(V node)
    Calculates the in-degree of a node.
    boolean isDirected()
    Indicates if the graph is directed.
    default boolean isMultigraph()
    Indicates if the graph is a multigraph (by default, it is not).
    default boolean isMutual​(V nodeA, V nodeB)
    Checks if an edge in the graph is mutual (a link from A to B and a link from B to A exists).
    boolean isWeighted()
    Indicates if the graph is weighted.
    int mutualDegree​(V node)
    Calculates the "mutual" degree of a node, i.e.
    int outDegree​(V node)
    Calculates the out-degree of a node.
    default boolean removeEdge​(V nodeA, V nodeB)
    Removes an edge from the graph.
    default boolean removeNode​(V node)
    Removes a node from the graph.
    boolean updateEdgeType​(V nodeA, V nodeB, int newType)
    Updates the type of an edge.
    boolean updateEdgeWeight​(V nodeA, V nodeB, double newWeight)
    Updates the weight of an edge.
  • Method Details

    • addNode

      boolean addNode​(V node)
      Adds a new node to the graph.
      Parameters:
      node - The new node to add.
      Returns:
      true if the node is correctly added, false if not.
    • addEdge

      default boolean addEdge​(V nodeA, V nodeB)
      Adds a new edge to the graph. If nodes do not exist, they are added.
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      Returns:
      true if the edge is correctly added, false if not.
    • addEdge

      default boolean addEdge​(V nodeA, V nodeB, boolean insertNodes)
      Adds an edge to the graph.
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      insertNodes - If true, nodes will be inserted if they do not exist. If false, the edge will only be added if both nodes are inserted.
      Returns:
      true if the edge is correctly added, false if not
    • addEdge

      default boolean addEdge​(V nodeA, V nodeB, double weight)
      Adds a new edge to the graph. If nodes do not exist, they are added.
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      weight - The weight of the edge.
      Returns:
      true if the edge is correctly added, false if not.
    • addEdge

      default boolean addEdge​(V nodeA, V nodeB, int type)
      Adds a new edge to the graph. If nodes do not exist, they are added.
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      type - The edge type.
      Returns:
      true if the edge is correctly added, false if not.
    • addEdge

      default boolean addEdge​(V nodeA, V nodeB, double weight, int type)
      Adds a new edge to the graph. If nodes do not exist, they are added.
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      weight - The weight of the edge.
      type - The edge type.
      Returns:
      true if the edge is correctly added, false if not.
    • addEdge

      boolean addEdge​(V nodeA, V nodeB, double weight, int type, boolean insertNodes)
      Adds a weighted edge to the graph.
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      weight - The weight.
      type - The edge type.
      insertNodes - If true, nodes will be inserted if they do not exist. If false, the edge will only be added if both nodes are inserted.
      Returns:
      if the edge is correctly added, false if not.
    • removeNode

      default boolean removeNode​(V node)
      Removes a node from the graph.
      Parameters:
      node - Node to remove.
      Returns:
      true if the edge is correctly removed, false if not.
    • removeEdge

      default boolean removeEdge​(V nodeA, V nodeB)
      Removes an edge from the graph.
      Parameters:
      nodeA - The incident node of the edge to remove.
      nodeB - The adjacent node of the edge to remove.
      Returns:
      true if everything went ok, false if not.
    • getAllNodes

      java.util.stream.Stream<V> getAllNodes()
      Gets all the nodes in the graph.
      Returns:
      a stream of all the nodes in the graph.
    • getIncidentNodes

      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.
      Parameters:
      node - The node.
      Returns:
      A stream of the incident nodes.
    • getAdjacentNodes

      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.
      Parameters:
      node - The node.
      Returns:
      A stream containing the adjacent nodes.
    • getMutualNodes

      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.
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes which share reciprocal links.
    • getNeighbourNodes

      java.util.stream.Stream<V> getNeighbourNodes​(V node)
      Given a node, finds all the nodes u so that either (node to u) or (u to node) are in the graph.
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood.
    • getNeighbourhood

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

      default int degree​(V node)
      Calculates the degree of a node.
      Parameters:
      node - The node.
      Returns:
      the degree of the node if it is contained in the graph, -1 otherwise.
    • inDegree

      int inDegree​(V node)
      Calculates the in-degree of a node.
      Parameters:
      node - The node.
      Returns:
      the in-degree of the node if it is contained in the graph, -1 otherwise.
    • outDegree

      int outDegree​(V node)
      Calculates the out-degree of a node.
      Parameters:
      node - The node.
      Returns:
      the out-degree of the node if it is contained in the graph, -1 otherwise.
    • mutualDegree

      int mutualDegree​(V node)
      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.
      Parameters:
      node - the node.
      Returns:
      the mutual degree of the node if it is contained in the graph, -1 otherwise.
    • degree

      int degree​(V node, EdgeOrientation orientation)
      Obtains the degree of a node, depending on the neighborhood selection.
      Parameters:
      node - The node whose degree we want to find.
      orientation - The neighborhood selection.
      Returns:
      the degree.
    • getIncidentNodesCount

      default int getIncidentNodesCount​(V node)
      Calculates the number of incident edges of a node (not necessarily equal to the in-degree).
      Parameters:
      node - The node.
      Returns:
      the number of incident neighbours of the node if it is contained in the graph, -1 if not.
    • getAdjacentNodesCount

      default int getAdjacentNodesCount​(V node)
      Calculates the number of adjacent edges of a node (not necessarily equal to the out-degree).
      Parameters:
      node - The node
      Returns:
      the degree of the node if it is contained in the graph, -1 if not.
    • getNeighbourNodesCount

      default int getNeighbourNodesCount​(V node)
      Calculates the total number of edges which reach a node or start from it (not necessarily equal to the degree).
      Parameters:
      node - The node
      Returns:
      the degree of the node if it is contained in the graph, -1 if not.
    • 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.
      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.
    • getNeighbourhoodSize

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

      int getIncidentEdgesCount​(V node)
      Calculates the number of incident edges of a node (not necessarily equal to the in-degree).
      Parameters:
      node - The node.
      Returns:
      the number of incident neighbours of the node if it is contained in the graph, -1 if not.
    • getAdjacentEdgesCount

      int getAdjacentEdgesCount​(V node)
      Calculates the number of adjacent edges of a node (not necessarily equal to the out-degree).
      Parameters:
      node - The node.
      Returns:
      the degree of the node if it is contained in the graph, -1 if not.
    • getNeighbourEdgesCount

      int getNeighbourEdgesCount​(V node)
      Calculates the total number of edges which reach a node or start from it (not necessarily equal to the degree).
      Parameters:
      node - The node.
      Returns:
      the degree of the node if it is contained in the graph, -1 if not.
    • getMutualEdgesCount

      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.
      Parameters:
      node - The node.
      Returns:
      the number of reciprocal links starting from the node.
    • containsVertex

      boolean containsVertex​(V node)
      Checks if a vertex exists in the graph.
      Parameters:
      node - The vertex to check.
      Returns:
      true if the vertex is contained in the graph, false if not.
    • containsEdge

      boolean containsEdge​(V nodeA, V nodeB)
      Checks if an edge exists in the graph.
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      Returns:
      true if the edge is contained in the graph, false if not.
    • isMutual

      default boolean isMutual​(V nodeA, V nodeB)
      Checks if an edge in the graph is mutual (a link from A to B and a link from B to A exists).
      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).
    • getEdgeWeight

      double getEdgeWeight​(V nodeA, V nodeB)
      Obtains the weight of an edge in the graph
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      Returns:
      The corresponding weight. If the edge does not exist, NaN
    • updateEdgeWeight

      boolean updateEdgeWeight​(V nodeA, V nodeB, double newWeight)
      Updates the weight of an edge.
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      newWeight - The new weight.
      Returns:
      true if everything goes OK, false if the edge does not exist or something fails.
    • getIncidentNodesWeights

      java.util.stream.Stream<Weight<V,​java.lang.Double>> getIncidentNodesWeights​(V node)
      Given a node, finds the weights of the edges from the nodes u such that the edge (u to node) is in the graph.
      Parameters:
      node - The node.
      Returns:
      A stream containing the adjacent nodes and weights.
    • getAdjacentNodesWeights

      java.util.stream.Stream<Weight<V,​java.lang.Double>> getAdjacentNodesWeights​(V node)
      Given a node, finds the weights of the edges towards the nodes u such that the edge (node to u) is in the graph.
      Parameters:
      node - The node.
      Returns:
      A stream containing the adjacent nodes and weights.
    • getNeighbourNodesWeights

      java.util.stream.Stream<Weight<V,​java.lang.Double>> getNeighbourNodesWeights​(V node)
      Given a node, finds the weights of the edges from the nodes u such that the edge (node to u) or the edge (u to node) are in the graph.
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and weights.
    • getAdjacentMutualNodesWeights

      java.util.stream.Stream<Weight<V,​java.lang.Double>> getAdjacentMutualNodesWeights​(V node)
      Given a node, finds the weights of the edges towards the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and weights.
    • getIncidentMutualNodesWeights

      java.util.stream.Stream<Weight<V,​java.lang.Double>> getIncidentMutualNodesWeights​(V node)
      Given a node, finds the weights of the edges from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph.
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and weights.
    • getMutualNodesWeights

      java.util.stream.Stream<Weight<V,​java.lang.Double>> getMutualNodesWeights​(V node)
      Given a node, finds the weights of the edges towards and from the nodes u such that the edge (node to u) and the edge (u to node) are in the graph. It finds the average value of the outgoing and incoming links.
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and weights.
    • getNeighbourhoodWeights

      java.util.stream.Stream<Weight<V,​java.lang.Double>> getNeighbourhoodWeights​(V node, EdgeOrientation direction)
      Gets all the weights of the edges in the neighbourhood of a node given by a direction. In the mutual case, just returns the average of the edge weights.
      Parameters:
      node - The node.
      direction - The direction of the links
      Returns:
      A stream containing the corresponding neighbourhood and weights.
    • getEdgeType

      int getEdgeType​(V nodeA, V nodeB)
      Obtains the type of an edge in the graph
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      Returns:
      The corresponding type. If the edge does not exist, -1.
    • updateEdgeType

      boolean updateEdgeType​(V nodeA, V nodeB, int newType)
      Updates the type of an edge.
      Parameters:
      nodeA - The incident node.
      nodeB - The adjacent node.
      newType - The new type.
      Returns:
      true if everything goes OK, false if the edge does not exist or something fails.
    • getIncidentNodesTypes

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

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

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

      java.util.stream.Stream<Weight<V,​java.lang.Integer>> getMutualNodesTypes​(V node)
      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.
      Parameters:
      node - the node.
      Returns:
      a stream containing all the nodes in the neighbourhood and types.
    • getAdjacentMutualNodesTypes

      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.
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and types.
    • getIncidentMutualNodesTypes

      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.
      Parameters:
      node - The node.
      Returns:
      A stream containing all the nodes in the neighbourhood and types.
    • getNeighbourhoodTypes

      java.util.stream.Stream<Weight<V,​java.lang.Integer>> getNeighbourhoodTypes​(V node, EdgeOrientation direction)
      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.
      Parameters:
      node - The node.
      direction - The direction of the links.
      Returns:
      A stream containing the corresponding neighbourhood.
    • isDirected

      boolean isDirected()
      Indicates if the graph is directed.
      Returns:
      true if it is, false if not.
    • isWeighted

      boolean isWeighted()
      Indicates if the graph is weighted.
      Returns:
      true if it is, false if not.
    • isMultigraph

      default boolean isMultigraph()
      Indicates if the graph is a multigraph (by default, it is not).
      Returns:
      true if it is, false if not.
    • getVertexCount

      long getVertexCount()
      Measures the number of nodes in the network.
      Returns:
      the number of nodes.
    • getEdgeCount

      long getEdgeCount()
      Measures the number of edges in the network.
      Returns:
      the number of edges.
    • getAdjacencyMatrix

      double[][] getAdjacencyMatrix​(EdgeOrientation direction)
      Gets the adjacency matrix.
      Parameters:
      direction - The direction of the edges.
      Returns:
      the adjacency matrix.
    • getAdjacencyMatrixMap

      Index<V> getAdjacencyMatrixMap()
      For an adjacency matrix, obtains the mapping between indexes and nodes.
      Returns:
      the mapping between indexes and nodes.
    • getIsolatedNodes

      java.util.stream.Stream<V> getIsolatedNodes()
      Obtains the set of nodes without edges.
      Returns:
      the set of nodes without edges.
    • getNodesWithNeighbors

      java.util.stream.Stream<V> getNodesWithNeighbors​(EdgeOrientation direction)
      Obtains the set of nodes with edges in a particular direction.
      Parameters:
      direction - the particular direction
      Returns:
      the set of nodes with edges in the given direction.
    • getNodesWithAdjacentNeighbors

      java.util.stream.Stream<V> getNodesWithAdjacentNeighbors()
      Obtains the set of nodes which have adjacent edges.
      Returns:
      the set of nodes which have adjacent edges.
    • getNodesWithIncidentNeighbors

      java.util.stream.Stream<V> getNodesWithIncidentNeighbors()
      Obtains the set of nodes which have incident edges.
      Returns:
      the set of nodes which have incident edges.
    • getNodesWithNeighbors

      java.util.stream.Stream<V> getNodesWithNeighbors()
      Obtains the set of nodes having either incident or adjacent edges.
      Returns:
      the set of nodes which have incident or adjacent edges.
    • getNodesWithMutualNeighbors

      java.util.stream.Stream<V> getNodesWithMutualNeighbors()
      Obtains the set of nodes having mutual edges.
      Returns:
      the set of nodes which have mutual edges.
    • hasAdjacentNeighbors

      boolean hasAdjacentNeighbors​(V u)
      Checks if the user has adjacent edges or not.
      Parameters:
      u - The user.
      Returns:
      true if the user has adjacent edges, false if it is a sink or isolated node.
    • hasIncidentNeighbors

      boolean hasIncidentNeighbors​(V u)
      Checks if the user has incident edges or not.
      Parameters:
      u - the user.
      Returns:
      true if the user has incident edges, false if it is a source or isolated node.
    • hasNeighbors

      boolean hasNeighbors​(V u)
      Checks if the user shares at least an edge with other user.
      Parameters:
      u - The user.
      Returns:
      true if the user is not isolated, false otherwise.
    • hasMutualNeighbors

      boolean hasMutualNeighbors​(V u)
      Checks if the user has mutual edges.
      Parameters:
      u - The user.
      Returns:
      true if the user has mutual edges, false otherwise.
    • hasNeighbors

      default boolean hasNeighbors​(V u, EdgeOrientation orient)
      Checks if the user has neighbors.
      Parameters:
      u - The user.
      orient - the orientation of the neighborhood.
      Returns:
      true if the user has neighbors.
    • complement

      Graph<V> complement()
      Complements the graph
      Returns:
      the complementary graph.