Class AbstractFastMultiGraph<U>
java.lang.Object
es.uam.eps.ir.relison.graph.multigraph.fast.AbstractFastMultiGraph<U>
- Type Parameters:
U
- User type
- All Implemented Interfaces:
FastGraph<U>
,Graph<U>
,FastMultiGraph<U>
,MultiGraph<U>
,ReducedIndex<U>
,java.io.Serializable
- Direct Known Subclasses:
FastDirectedUnweightedMultiGraph
,FastDirectedWeightedMultiGraph
,FastUndirectedUnweightedMultiGraph
,FastUndirectedWeightedMultiGraph
public abstract class AbstractFastMultiGraph<U> extends java.lang.Object implements FastMultiGraph<U>, java.io.Serializable
Fast implementation of a multi graph
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected MultiEdges
edges
Edges in the networkprotected Index<U>
vertices
Index of vertices -
Constructor Summary
Constructors Constructor Description AbstractFastMultiGraph(Index<U> vertices, MultiEdges edges)
Constructor -
Method Summary
Modifier and Type Method Description boolean
addEdge(int nodeA, int nodeB, double weight, int type)
Uncontrolled edge addition method, using ids.boolean
addEdge(U nodeA, U nodeB, double weight, int type, boolean insertNodes)
Adds a weighted edge to the graph.boolean
addNode(U node)
Adds a new node to the graph.Graph<U>
complement()
Complements the graphboolean
containsEdge(int uidx, int vidx)
Checks whether the network contains an edge or not.boolean
containsEdge(U nodeA, U nodeB)
Checks if an edge exists in the graph.boolean
containsVertex(U node)
Checks if a vertex exists in the graph.Index<U>
getAdjacencyMatrixMap()
For an adjacency matrix, obtains the mapping between indexes and nodes.int
getAdjacentEdgesCount(U node)
Calculates the number of adjacent edges of a node (not necessarily equal to the out-degree).java.util.stream.Stream<U>
getAdjacentNodes(U node)
Given a node, finds all the nodes u such that the edge (node to u) is in the graph.java.util.stream.Stream<Weight<U,java.lang.Integer>>
getAdjacentNodesTypes(U 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<Weights<U,java.lang.Integer>>
getAdjacentNodesTypesLists(U node)
Gets the different weights for the edges of the adjacent nodes.java.util.stream.Stream<Weight<U,java.lang.Double>>
getAdjacentNodesWeights(U 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<Weights<U,java.lang.Double>>
getAdjacentNodesWeightsLists(U node)
Gets the different weights for the edges of the adjacent nodes.java.util.stream.Stream<U>
getAllNodes()
Gets all the nodes in the graph.java.util.stream.IntStream
getAllNodesIds()
Obtains the identifiers of all the nodes in the network.long
getEdgeCount()
Measures the number of edges in the network.int
getEdgeType(U nodeA, U nodeB)
Obtains the type of an edge in the graphjava.util.List<java.lang.Integer>
getEdgeTypes(int uidx, int vidx)
Obtains the list of types of the edges between a pair of vertices.java.util.List<java.lang.Integer>
getEdgeTypes(U nodeA, U nodeB)
Gets the weights of the different edges between two nodes, A and B.double
getEdgeWeight(int uidx, int vidx)
Obtains the weight of an edge, given the identifiers of the involved nodes.double
getEdgeWeight(U nodeA, U nodeB)
Obtains the weight of an edge in the graphjava.util.List<java.lang.Double>
getEdgeWeights(int uidx, int vidx)
Obtains the list of weights of the edges between a pair of vertices.java.util.List<java.lang.Double>
getEdgeWeights(U nodeA, U nodeB)
Gets the weights of the different edges between two nodes, A and B.int
getIncidentEdgesCount(U node)
Calculates the number of incident edges of a node (not necessarily equal to the in-degree).java.util.stream.Stream<U>
getIncidentNodes(U node)
Given a node, finds all the nodes u such that the edge (u to node) is in the graph.java.util.stream.Stream<Weight<U,java.lang.Integer>>
getIncidentNodesTypes(U 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<Weights<U,java.lang.Integer>>
getIncidentNodesTypesLists(U node)
Gets the different weights for the edges of the incident nodes.java.util.stream.Stream<Weight<U,java.lang.Double>>
getIncidentNodesWeights(U 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<Weights<U,java.lang.Double>>
getIncidentNodesWeightsLists(U node)
Gets the different weights for the edges of the incident nodes.Index<U>
getIndex()
Obtains the index for the vertices.java.util.stream.IntStream
getIsolatedNodeIds()
Obtains the set of isolated nodes in the graph.java.util.stream.Stream<U>
getIsolatedNodes()
Obtains the set of nodes without edges.java.util.stream.Stream<java.lang.Integer>
getNeighborhood(int uidx, EdgeOrientation orientation)
Obtains the neighborhood of a node, given its identifier.java.util.stream.Stream<EdgeType>
getNeighborhoodTypes(int uidx, EdgeOrientation orientation)
Obtains the neighborhood of a node and the type of the edges to each other, given its identifier.java.util.stream.Stream<es.uam.eps.ir.ranksys.fast.preference.IdxPref>
getNeighborhoodWeights(int uidx, EdgeOrientation orientation)
Obtains the neighborhood of a node and the weight of the edges to each other, given its identifier.int
getNeighbourEdgesCount(U 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<U>
getNeighbourhood(U node, EdgeOrientation direction)
Gets all the nodes in the neighbourhood of a node given by a direction.int
getNeighbourhoodSize(U node, EdgeOrientation direction)
Gets all the nodes in the neighbourhood of a node given by a direction.java.util.stream.Stream<Weight<U,java.lang.Integer>>
getNeighbourhoodTypes(U node, EdgeOrientation direction)
Gets all the types of the edges in the neighbourhood of a node given by a direction.java.util.stream.Stream<MultiEdgeTypes>
getNeighbourhoodTypesLists(int uidx, EdgeOrientation orientation)
Gets the different types for the edges of the selected neighbour nodes of a node.java.util.stream.Stream<Weight<U,java.lang.Double>>
getNeighbourhoodWeights(U node, EdgeOrientation direction)
Gets all the weights of the edges in the neighbourhood of a node given by a direction.java.util.stream.Stream<MultiEdgeWeights>
getNeighbourhoodWeightsLists(int uidx, EdgeOrientation orientation)
Gets the different weights for the edges of the selected neighbour nodes of a node.java.util.stream.Stream<Weights<U,java.lang.Double>>
getNeighbourhoodWeightsLists(U node, EdgeOrientation orientation)
Gets the different weights for the edges of the selected neighbour nodes.java.util.stream.Stream<U>
getNeighbourNodes(U node)
Given a node, finds all the nodes u so that either (node to u) or (u to node) are in the graph.java.util.stream.Stream<Weight<U,java.lang.Integer>>
getNeighbourNodesTypes(U 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<Weights<U,java.lang.Integer>>
getNeighbourNodesTypesLists(U node)
Gets the different weights for the edges of the neighbour nodes.java.util.stream.Stream<Weight<U,java.lang.Double>>
getNeighbourNodesWeights(U 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<Weights<U,java.lang.Double>>
getNeighbourNodesWeightsLists(U node)
Gets the different weights for the edges of the neighbour nodes.java.util.stream.IntStream
getNodesIdsWithEdges(EdgeOrientation direction)
Obtains the identifiers of the nodes which have edges.java.util.stream.Stream<U>
getNodesWithAdjacentNeighbors()
Obtains the set of nodes which have adjacent edges.java.util.stream.Stream<U>
getNodesWithIncidentNeighbors()
Obtains the set of nodes which have incident edges.java.util.stream.Stream<U>
getNodesWithMutualNeighbors()
Obtains the set of nodes having mutual edges.java.util.stream.Stream<U>
getNodesWithNeighbors()
Obtains the set of nodes having either incident or adjacent edges.java.util.stream.Stream<U>
getNodesWithNeighbors(EdgeOrientation orient)
Obtains the set of nodes with edges in a particular direction.int
getNumEdges(int uidx, int vidx)
Obtains the number of edges between a pair of vertices.int
getNumEdges(U nodeA, U nodeB)
Gets the number of edges between two nodes, A and B.long
getVertexCount()
Measures the number of nodes in the network.boolean
hasAdjacentNeighbors(U u)
Checks if the user has adjacent edges or not.boolean
hasIncidentNeighbors(U u)
Checks if the user has incident edges or not.boolean
hasMutualNeighbors(U u)
Checks if the user has mutual edges.boolean
hasNeighbors(U u)
Checks if the user shares at least an edge with other user.U
idx2object(int idx)
Gets the object corresponding to a certain index.int
object2idx(U u)
Gets the index of a given object.boolean
removeEdge(U nodeA, U nodeB)
Removes an edge from the graph.boolean
removeEdge(U nodeA, U nodeB, int idx)
Removes an edge from the graph.boolean
removeEdges(U nodeA, U nodeB)
Deletes all the edges between a pair of nodes.boolean
removeNode(U node)
Removes a node from the graph.boolean
updateEdgeType(U orig, U dest, int type)
Updates the type of an edge.boolean
updateEdgeWeight(int nodeA, int nodeB, double weight)
Uncontrolled edge update method, using ids.boolean
updateEdgeWeight(int uidx, int vidx, double weight, int idx)
Updates the weight of an edge from the graph.boolean
updateEdgeWeight(U orig, U dest, double weight)
Updates the weight of an edge.boolean
updateEdgeWeight(U orig, U dest, double weight, int idx)
Updates the weight of an edge from the graph.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface es.uam.eps.ir.relison.graph.Graph
addEdge, addEdge, addEdge, addEdge, addEdge, degree, degree, getAdjacencyMatrix, getAdjacentMutualNodesTypes, getAdjacentMutualNodesWeights, getAdjacentNodesCount, getIncidentMutualNodesTypes, getIncidentMutualNodesWeights, getIncidentNodesCount, getMutualEdgesCount, getMutualNodes, getMutualNodesCount, getMutualNodesTypes, getMutualNodesWeights, getNeighbourNodesCount, hasNeighbors, inDegree, isDirected, isMutual, isWeighted, mutualDegree, outDegree
Methods inherited from interface es.uam.eps.ir.relison.graph.multigraph.MultiGraph
getNeighbourhoodTypesLists, isMultigraph
-
Field Details
-
Constructor Details
-
AbstractFastMultiGraph
Constructor- Parameters:
vertices
- A index for the vertices of the graphedges
- Edges
-
-
Method Details
-
addNode
Description copied from interface:Graph
Adds a new node to the graph. -
addEdge
Description copied from interface:Graph
Adds a weighted edge to the graph.- Specified by:
addEdge
in interfaceGraph<U>
- 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.
-
getAllNodes
Description copied from interface:Graph
Gets all the nodes in the graph.- Specified by:
getAllNodes
in interfaceGraph<U>
- Returns:
- a stream of all the nodes in the graph.
-
getIncidentNodes
Description copied from interface:Graph
Given a node, finds all the nodes u such that the edge (u to node) is in the graph.- Specified by:
getIncidentNodes
in interfaceGraph<U>
- Parameters:
node
- The node.- Returns:
- A stream of the incident nodes.
-
getAdjacentNodes
Description copied from interface:Graph
Given a node, finds all the nodes u such that the edge (node to u) is in the graph.- Specified by:
getAdjacentNodes
in interfaceGraph<U>
- Parameters:
node
- The node.- Returns:
- A stream containing the adjacent nodes.
-
getNeighbourNodes
Description copied from interface:Graph
Given a node, finds all the nodes u so that either (node to u) or (u to node) are in the graph.- Specified by:
getNeighbourNodes
in interfaceGraph<U>
- Parameters:
node
- The node.- Returns:
- A stream containing all the nodes in the neighbourhood.
-
getNeighbourhood
Description copied from interface:Graph
Gets all the nodes in the neighbourhood of a node given by a direction.- Specified by:
getNeighbourhood
in interfaceGraph<U>
- Parameters:
node
- The node.direction
- The direction of the links.- Returns:
- A stream containing the corresponding neighbourhood.
-
getIncidentEdgesCount
Description copied from interface:Graph
Calculates the number of incident edges of a node (not necessarily equal to the in-degree).- Specified by:
getIncidentEdgesCount
in interfaceGraph<U>
- Parameters:
node
- The node.- Returns:
- the number of incident neighbours of the node if it is contained in the graph, -1 if not.
-
getAdjacentEdgesCount
Description copied from interface:Graph
Calculates the number of adjacent edges of a node (not necessarily equal to the out-degree).- Specified by:
getAdjacentEdgesCount
in interfaceGraph<U>
- Parameters:
node
- The node.- Returns:
- the degree of the node if it is contained in the graph, -1 if not.
-
getNeighbourEdgesCount
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 interfaceGraph<U>
- Parameters:
node
- The node.- Returns:
- the degree of the node if it is contained in the graph, -1 if not.
-
getNeighbourhoodSize
Description copied from interface:Graph
Gets all the nodes in the neighbourhood of a node given by a direction.- Specified by:
getNeighbourhoodSize
in interfaceGraph<U>
- Parameters:
node
- The node.direction
- The direction of the links.- Returns:
- A stream containing the corresponding neighbourhood.
-
containsVertex
Description copied from interface:Graph
Checks if a vertex exists in the graph.- Specified by:
containsVertex
in interfaceGraph<U>
- Parameters:
node
- The vertex to check.- Returns:
- true if the vertex is contained in the graph, false if not.
-
containsEdge
Description copied from interface:Graph
Checks if an edge exists in the graph.- Specified by:
containsEdge
in interfaceGraph<U>
- Parameters:
nodeA
- The incident node.nodeB
- The adjacent node.- Returns:
- true if the edge is contained in the graph, false if not.
-
getEdgeWeight
Description copied from interface:Graph
Obtains the weight of an edge in the graph- Specified by:
getEdgeWeight
in interfaceGraph<U>
- Parameters:
nodeA
- The incident node.nodeB
- The adjacent node.- Returns:
- The corresponding weight. If the edge does not exist, NaN
-
getIncidentNodesWeights
Description copied from interface:Graph
Given a node, finds the weights of the edges from the nodes u such that the edge (u to node) is in the graph.- Specified by:
getIncidentNodesWeights
in interfaceGraph<U>
- Parameters:
node
- The node.- Returns:
- A stream containing the adjacent nodes and weights.
-
getAdjacentNodesWeights
Description copied from interface:Graph
Given a node, finds the weights of the edges towards the nodes u such that the edge (node to u) is in the graph.- Specified by:
getAdjacentNodesWeights
in interfaceGraph<U>
- Parameters:
node
- The node.- Returns:
- A stream containing the adjacent nodes and weights.
-
getNeighbourNodesWeights
Description copied from interface:Graph
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.- Specified by:
getNeighbourNodesWeights
in interfaceGraph<U>
- Parameters:
node
- The node.- Returns:
- A stream containing all the nodes in the neighbourhood and weights.
-
getNeighbourhoodWeights
public java.util.stream.Stream<Weight<U,java.lang.Double>> getNeighbourhoodWeights(U node, EdgeOrientation direction)Description copied from interface:Graph
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.- Specified by:
getNeighbourhoodWeights
in interfaceGraph<U>
- Parameters:
node
- The node.direction
- The direction of the links- Returns:
- A stream containing the corresponding neighbourhood and weights.
-
getEdgeType
Description copied from interface:Graph
Obtains the type of an edge in the graph- Specified by:
getEdgeType
in interfaceGraph<U>
- Parameters:
nodeA
- The incident node.nodeB
- The adjacent node.- Returns:
- The corresponding type. If the edge does not exist, -1.
-
getIncidentNodesTypes
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 interfaceGraph<U>
- Parameters:
node
- The node.- Returns:
- A stream of the incident nodes and types.
-
getAdjacentNodesTypes
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 interfaceGraph<U>
- Parameters:
node
- The node.- Returns:
- A stream containing the adjacent nodes and types.
-
getNeighbourNodesTypes
Description copied from interface:Graph
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.- Specified by:
getNeighbourNodesTypes
in interfaceGraph<U>
- Parameters:
node
- The node.- Returns:
- A stream containing all the nodes in the neighbourhood and types.
-
getNeighbourhoodTypes
public java.util.stream.Stream<Weight<U,java.lang.Integer>> getNeighbourhoodTypes(U 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 interfaceGraph<U>
- Parameters:
node
- The node.direction
- The direction of the links.- Returns:
- A stream containing the corresponding neighbourhood.
-
getVertexCount
public long getVertexCount()Description copied from interface:Graph
Measures the number of nodes in the network.- Specified by:
getVertexCount
in interfaceGraph<U>
- Returns:
- the number of nodes.
-
getNumEdges
Description copied from interface:MultiGraph
Gets the number of edges between two nodes, A and B.- Specified by:
getNumEdges
in interfaceMultiGraph<U>
- Parameters:
nodeA
- The first node of the pair.nodeB
- The second node of the pair.- Returns:
- The number of edges between the nodes.
-
getEdgeWeights
Description copied from interface:MultiGraph
Gets the weights of the different edges between two nodes, A and B.- Specified by:
getEdgeWeights
in interfaceMultiGraph<U>
- Parameters:
nodeA
- The first node of the pair.nodeB
- THe second node of the pair.- Returns:
- The number of edges between the nodes.
-
getIncidentNodesWeightsLists
Description copied from interface:MultiGraph
Gets the different weights for the edges of the incident nodes.- Specified by:
getIncidentNodesWeightsLists
in interfaceMultiGraph<U>
- Parameters:
node
- The node to study- Returns:
- A stream containing the weights
-
getAdjacentNodesWeightsLists
Description copied from interface:MultiGraph
Gets the different weights for the edges of the adjacent nodes.- Specified by:
getAdjacentNodesWeightsLists
in interfaceMultiGraph<U>
- Parameters:
node
- The node to study- Returns:
- A stream containing the weights
-
getNeighbourNodesWeightsLists
Description copied from interface:MultiGraph
Gets the different weights for the edges of the neighbour nodes.- Specified by:
getNeighbourNodesWeightsLists
in interfaceMultiGraph<U>
- Parameters:
node
- The node to study- Returns:
- A stream containing the weights
-
getNeighbourhoodWeightsLists
public java.util.stream.Stream<Weights<U,java.lang.Double>> getNeighbourhoodWeightsLists(U node, EdgeOrientation orientation)Description copied from interface:MultiGraph
Gets the different weights for the edges of the selected neighbour nodes.- Specified by:
getNeighbourhoodWeightsLists
in interfaceMultiGraph<U>
- Parameters:
node
- The node to studyorientation
- The orientation to take- Returns:
- A stream containing the weights
-
getEdgeTypes
Description copied from interface:MultiGraph
Gets the weights of the different edges between two nodes, A and B.- Specified by:
getEdgeTypes
in interfaceMultiGraph<U>
- Parameters:
nodeA
- The first node of the pair.nodeB
- THe second node of the pair.- Returns:
- The number of edges between the nodes.
-
getIncidentNodesTypesLists
Description copied from interface:MultiGraph
Gets the different weights for the edges of the incident nodes.- Specified by:
getIncidentNodesTypesLists
in interfaceMultiGraph<U>
- Parameters:
node
- The node to study- Returns:
- A stream containing the weights
-
getAdjacentNodesTypesLists
Description copied from interface:MultiGraph
Gets the different weights for the edges of the adjacent nodes.- Specified by:
getAdjacentNodesTypesLists
in interfaceMultiGraph<U>
- Parameters:
node
- The node to study- Returns:
- A stream containing the weights
-
getNeighbourNodesTypesLists
Description copied from interface:MultiGraph
Gets the different weights for the edges of the neighbour nodes.- Specified by:
getNeighbourNodesTypesLists
in interfaceMultiGraph<U>
- Parameters:
node
- The node to study- Returns:
- A stream containing the weights
-
getEdgeCount
public long getEdgeCount()Description copied from interface:Graph
Measures the number of edges in the network.- Specified by:
getEdgeCount
in interfaceGraph<U>
- Returns:
- the number of edges.
-
complement
Description copied from interface:Graph
Complements the graph- Specified by:
complement
in interfaceGraph<U>
- Returns:
- the complementary graph.
-
updateEdgeWeight
Description copied from interface:Graph
Updates the weight of an edge.- Specified by:
updateEdgeWeight
in interfaceGraph<U>
- Parameters:
orig
- The incident node.dest
- The adjacent node.weight
- The new weight.- Returns:
- true if everything goes OK, false if the edge does not exist or something fails.
-
updateEdgeType
Description copied from interface:Graph
Updates the type of an edge.- Specified by:
updateEdgeType
in interfaceGraph<U>
- Parameters:
orig
- The incident node.dest
- The adjacent node.type
- The new type.- Returns:
- true if everything goes OK, false if the edge does not exist or something fails.
-
object2idx
Description copied from interface:ReducedIndex
Gets the index of a given object.- Specified by:
object2idx
in interfaceReducedIndex<U>
- Parameters:
u
- Object to obtain.- Returns:
- the index if the object exists, -1 if not.
-
idx2object
Description copied from interface:ReducedIndex
Gets the object corresponding to a certain index.- Specified by:
idx2object
in interfaceReducedIndex<U>
- Parameters:
idx
- The index.- Returns:
- the object corresponding to the index.
-
getIsolatedNodes
Description copied from interface:Graph
Obtains the set of nodes without edges.- Specified by:
getIsolatedNodes
in interfaceGraph<U>
- Returns:
- the set of nodes without edges.
-
getNodesWithNeighbors
Description copied from interface:Graph
Obtains the set of nodes with edges in a particular direction.- Specified by:
getNodesWithNeighbors
in interfaceGraph<U>
- Parameters:
orient
- the particular direction- Returns:
- the set of nodes with edges in the given direction.
-
getNodesWithAdjacentNeighbors
Description copied from interface:Graph
Obtains the set of nodes which have adjacent edges.- Specified by:
getNodesWithAdjacentNeighbors
in interfaceGraph<U>
- Returns:
- the set of nodes which have adjacent edges.
-
getNodesWithIncidentNeighbors
Description copied from interface:Graph
Obtains the set of nodes which have incident edges.- Specified by:
getNodesWithIncidentNeighbors
in interfaceGraph<U>
- Returns:
- the set of nodes which have incident edges.
-
getNodesWithNeighbors
Description copied from interface:Graph
Obtains the set of nodes having either incident or adjacent edges.- Specified by:
getNodesWithNeighbors
in interfaceGraph<U>
- Returns:
- the set of nodes which have incident or adjacent edges.
-
getNodesWithMutualNeighbors
Description copied from interface:Graph
Obtains the set of nodes having mutual edges.- Specified by:
getNodesWithMutualNeighbors
in interfaceGraph<U>
- Returns:
- the set of nodes which have mutual edges.
-
hasAdjacentNeighbors
Description copied from interface:Graph
Checks if the user has adjacent edges or not.- Specified by:
hasAdjacentNeighbors
in interfaceGraph<U>
- Parameters:
u
- The user.- Returns:
- true if the user has adjacent edges, false if it is a sink or isolated node.
-
hasIncidentNeighbors
Description copied from interface:Graph
Checks if the user has incident edges or not.- Specified by:
hasIncidentNeighbors
in interfaceGraph<U>
- Parameters:
u
- the user.- Returns:
- true if the user has incident edges, false if it is a source or isolated node.
-
hasNeighbors
Description copied from interface:Graph
Checks if the user shares at least an edge with other user.- Specified by:
hasNeighbors
in interfaceGraph<U>
- Parameters:
u
- The user.- Returns:
- true if the user is not isolated, false otherwise.
-
hasMutualNeighbors
Description copied from interface:Graph
Checks if the user has mutual edges.- Specified by:
hasMutualNeighbors
in interfaceGraph<U>
- Parameters:
u
- The user.- Returns:
- true if the user has mutual edges, false otherwise.
-
getNeighbourhoodWeightsLists
public java.util.stream.Stream<MultiEdgeWeights> getNeighbourhoodWeightsLists(int uidx, EdgeOrientation orientation)Description copied from interface:FastMultiGraph
Gets the different weights for the edges of the selected neighbour nodes of a node.- Specified by:
getNeighbourhoodWeightsLists
in interfaceFastMultiGraph<U>
- Parameters:
uidx
- The identifier of the node to studyorientation
- The orientation to take- Returns:
- A stream containing the weights
-
getNeighbourhoodTypesLists
public java.util.stream.Stream<MultiEdgeTypes> getNeighbourhoodTypesLists(int uidx, EdgeOrientation orientation)Description copied from interface:FastMultiGraph
Gets the different types for the edges of the selected neighbour nodes of a node.- Specified by:
getNeighbourhoodTypesLists
in interfaceFastMultiGraph<U>
- Parameters:
uidx
- The identifier of the node to studyorientation
- The orientation to take- Returns:
- A stream containing the types
-
getNumEdges
public int getNumEdges(int uidx, int vidx)Description copied from interface:FastMultiGraph
Obtains the number of edges between a pair of vertices.- Specified by:
getNumEdges
in interfaceFastMultiGraph<U>
- Parameters:
uidx
- the identifier of the source node.vidx
- the identifier of the destination node.- Returns:
- the number of edges between the pair of nodes.
-
getEdgeWeights
public java.util.List<java.lang.Double> getEdgeWeights(int uidx, int vidx)Description copied from interface:FastMultiGraph
Obtains the list of weights of the edges between a pair of vertices.- Specified by:
getEdgeWeights
in interfaceFastMultiGraph<U>
- Parameters:
uidx
- the identifier of the source node.vidx
- the identifier of the destination node.- Returns:
- the list of weights of the edges between the pair of nodes.
-
getEdgeTypes
public java.util.List<java.lang.Integer> getEdgeTypes(int uidx, int vidx)Description copied from interface:FastMultiGraph
Obtains the list of types of the edges between a pair of vertices.- Specified by:
getEdgeTypes
in interfaceFastMultiGraph<U>
- Parameters:
uidx
- the identifier of the source node.vidx
- the identifier of the destination node.- Returns:
- the list of types of the edges between the pair of nodes.
-
getIndex
Description copied from interface:FastGraph
Obtains the index for the vertices. -
getEdgeWeight
public double getEdgeWeight(int uidx, int vidx)Description copied from interface:FastGraph
Obtains the weight of an edge, given the identifiers of the involved nodes.- Specified by:
getEdgeWeight
in interfaceFastGraph<U>
- Parameters:
uidx
- identifier of the first user.vidx
- identifier of the second user.- Returns:
- the weight if it exists, an error value otherwise.
-
getNeighborhood
public java.util.stream.Stream<java.lang.Integer> getNeighborhood(int uidx, EdgeOrientation orientation)Description copied from interface:FastGraph
Obtains the neighborhood of a node, given its identifier.- Specified by:
getNeighborhood
in interfaceFastGraph<U>
- Parameters:
uidx
- the identifier of the node.orientation
- the orientation of the neighborhood to retrieve.- Returns:
- an stream containing the neighbors of the node.
-
getNeighborhoodWeights
public java.util.stream.Stream<es.uam.eps.ir.ranksys.fast.preference.IdxPref> getNeighborhoodWeights(int uidx, EdgeOrientation orientation)Description copied from interface:FastGraph
Obtains the neighborhood of a node and the weight of the edges to each other, given its identifier.- Specified by:
getNeighborhoodWeights
in interfaceFastGraph<U>
- Parameters:
uidx
- the identifier of the node.orientation
- the orientation of the neighborhood to retrieve.- Returns:
- an stream containing the weights of neighbors of the node.
-
getNeighborhoodTypes
public java.util.stream.Stream<EdgeType> getNeighborhoodTypes(int uidx, EdgeOrientation orientation)Description copied from interface:FastGraph
Obtains the neighborhood of a node and the type of the edges to each other, given its identifier.- Specified by:
getNeighborhoodTypes
in interfaceFastGraph<U>
- Parameters:
uidx
- the identifier of the node.orientation
- the orientation of the neighborhood to retrieve.- Returns:
- an stream containing the edge types of the neighbors of the node.
-
getAllNodesIds
public java.util.stream.IntStream getAllNodesIds()Description copied from interface:FastGraph
Obtains the identifiers of all the nodes in the network.- Specified by:
getAllNodesIds
in interfaceFastGraph<U>
- Returns:
- an stream containing the vertex identifiers.
-
containsEdge
public boolean containsEdge(int uidx, int vidx)Description copied from interface:FastGraph
Checks whether the network contains an edge or not.- Specified by:
containsEdge
in interfaceFastGraph<U>
- Parameters:
uidx
- the identifier of the first vertexvidx
- the identifier of the second vertex- Returns:
- true if the edge exists, false otherwise.
-
addEdge
public boolean addEdge(int nodeA, int nodeB, double weight, int type)Description copied from interface:FastGraph
Uncontrolled edge addition method, using ids. -
updateEdgeWeight
public boolean updateEdgeWeight(int nodeA, int nodeB, double weight)Description copied from interface:FastGraph
Uncontrolled edge update method, using ids.- Specified by:
updateEdgeWeight
in interfaceFastGraph<U>
- Parameters:
nodeA
- Identifier of the first node.nodeB
- Identifier of the second node.weight
- Weight of the link.- Returns:
- true if everything went ok, false otherwise.
-
getNodesIdsWithEdges
Description copied from interface:FastGraph
Obtains the identifiers of the nodes which have edges.- Specified by:
getNodesIdsWithEdges
in interfaceFastGraph<U>
- Parameters:
direction
- the orientation selection.- Returns:
- a stream containing the corresponding nodes.
-
getIsolatedNodeIds
public java.util.stream.IntStream getIsolatedNodeIds()Description copied from interface:FastGraph
Obtains the set of isolated nodes in the graph.- Specified by:
getIsolatedNodeIds
in interfaceFastGraph<U>
- Returns:
- a stream containing the isolated nodes.
-
removeEdge
Description copied from interface:Graph
Removes an edge from the graph.- Specified by:
removeEdge
in interfaceGraph<U>
- 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.
-
removeEdge
Description copied from interface:MultiGraph
Removes an edge from the graph.- Specified by:
removeEdge
in interfaceMultiGraph<U>
- Parameters:
nodeA
- The incident node of the edge to remove.nodeB
- The adjacent node of the edge to remove.idx
- The number of the edge to remove.- Returns:
- true if everything went ok, false if not.
-
removeEdges
Description copied from interface:MultiGraph
Deletes all the edges between a pair of nodes.- Specified by:
removeEdges
in interfaceMultiGraph<U>
- Parameters:
nodeA
- The incident node of the edges to remove.nodeB
- The adjacent node of the edges to remove.- Returns:
- true if everything went ok, false otherwise.
-
removeNode
Description copied from interface:Graph
Removes a node from the graph.- Specified by:
removeNode
in interfaceGraph<U>
- Parameters:
node
- Node to remove.- Returns:
- true if the edge is correctly removed, false if not.
-
updateEdgeWeight
Description copied from interface:FastMultiGraph
Updates the weight of an edge from the graph.- Specified by:
updateEdgeWeight
in interfaceFastMultiGraph<U>
- Parameters:
orig
- The incident node of the edge to remove.dest
- The adjacent node of the edge to remove.weight
- the new weight for the edge.idx
- The number of the edge to remove.- Returns:
- true if everything went ok, false if not.
-
updateEdgeWeight
public boolean updateEdgeWeight(int uidx, int vidx, double weight, int idx)Description copied from interface:MultiGraph
Updates the weight of an edge from the graph.- Specified by:
updateEdgeWeight
in interfaceMultiGraph<U>
- Parameters:
uidx
- The incident node of the edge to remove.vidx
- The adjacent node of the edge to remove.weight
- the new weight for the edge.idx
- The number of the edge to remove.- Returns:
- true if everything went ok, false if not.
-
getAdjacencyMatrixMap
Description copied from interface:Graph
For an adjacency matrix, obtains the mapping between indexes and nodes.- Specified by:
getAdjacencyMatrixMap
in interfaceGraph<U>
- Returns:
- the mapping between indexes and nodes.
-