Class FastMultiEdges
java.lang.Object
es.uam.eps.ir.relison.graph.multigraph.edges.fast.FastMultiEdges
- All Implemented Interfaces:
MultiEdges
- Direct Known Subclasses:
FastDirectedUnweightedMultiEdges
,FastDirectedWeightedMultiEdges
,FastUndirectedUnweightedMultiEdges
,FastUndirectedWeightedMultiEdges
public abstract class FastMultiEdges extends java.lang.Object implements MultiEdges
Abstract fast implementation of class MultiEdges.
-
Field Summary
Fields Modifier and Type Field Description protected long
numEdges
Number of edges.protected AutoRelation<java.util.List<java.lang.Integer>>
types
Relation for storing the types of the edges.protected AutoRelation<java.util.List<java.lang.Double>>
weights
Relation for storing the weights of the edges. -
Constructor Summary
Constructors Constructor Description FastMultiEdges(AutoRelation<java.util.List<java.lang.Double>> weights, AutoRelation<java.util.List<java.lang.Integer>> types)
Constructor. -
Method Summary
Modifier and Type Method Description boolean
addUser(int node)
Adds a user to the edges.boolean
containsEdge(int orig, int dest)
Checks if an edge exists.int
getAdjacentCount(int dest)
Gets the number of adjacent edges to a nodejava.util.List<java.lang.Integer>
getEdgeTypes(int orig, int dest)
Gets the type of an edge.java.util.List<java.lang.Double>
getEdgeWeights(int orig, int dest)
Gets the weight of an edge.int
getIncidentCount(int dest)
Gets the number of incident edges to a nodejava.util.stream.IntStream
getIsolatedNodes()
Obtains the set of nodes which do not have any neighbor.long
getNumEdges()
Obtains the number of edgesint
getNumEdges(int orig, int dest)
Gets the number of existing edges between two destiniesboolean
hasAdjacentEdges(int node)
Checks if a node has adjacent edges.boolean
hasEdges(int node)
Checks if a node has adjacent or incident edges.boolean
hasIncidentEdges(int node)
Checks if a node has incident edges.boolean
hasMutualEdges(int node)
Checks if a node has mutual edges.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.multigraph.edges.MultiEdges
addEdge, getAdjacentNodes, getAdjacentTypes, getAdjacentWeights, getIncidentNodes, getIncidentTypes, getIncidentWeights, getMutualNodes, getMutualTypes, getMutualWeights, getNeighbourCount, getNeighbourNodes, getNeighbourTypes, getNeighbourWeights, getNodesWithAdjacentEdges, getNodesWithEdges, getNodesWithIncidentEdges, getNodesWithMutualEdges, removeEdge, removeEdges, removeNode, updateEdgeType, updateEdgeWeight
-
Field Details
-
Constructor Details
-
FastMultiEdges
public FastMultiEdges(AutoRelation<java.util.List<java.lang.Double>> weights, AutoRelation<java.util.List<java.lang.Integer>> types)Constructor.- Parameters:
weights
- The weights of the edges.types
- The types of the edges
-
-
Method Details
-
containsEdge
public boolean containsEdge(int orig, int dest)Description copied from interface:MultiEdges
Checks if an edge exists.- Specified by:
containsEdge
in interfaceMultiEdges
- Parameters:
orig
- The origin endpointdest
- The destiny endpoint- Returns:
- true if the edge exists, false if not.
-
getEdgeWeights
public java.util.List<java.lang.Double> getEdgeWeights(int orig, int dest)Description copied from interface:MultiEdges
Gets the weight of an edge.- Specified by:
getEdgeWeights
in interfaceMultiEdges
- Parameters:
orig
- The origin endpoint.dest
- The destiny endpoint.- Returns:
- the value if the edge exists, the default error value if not.
-
getEdgeTypes
public java.util.List<java.lang.Integer> getEdgeTypes(int orig, int dest)Description copied from interface:MultiEdges
Gets the type of an edge.- Specified by:
getEdgeTypes
in interfaceMultiEdges
- Parameters:
orig
- The origin endpoint.dest
- The destiny endpoint.- Returns:
- the type if the edge exists, the default error value if not.
-
addUser
public boolean addUser(int node)Description copied from interface:MultiEdges
Adds a user to the edges.- Specified by:
addUser
in interfaceMultiEdges
- Parameters:
node
- Identifier of the user- Returns:
- the user.
-
getNumEdges
public int getNumEdges(int orig, int dest)Description copied from interface:MultiEdges
Gets the number of existing edges between two destinies- Specified by:
getNumEdges
in interfaceMultiEdges
- Parameters:
orig
- The origin endpointdest
- The destiny endpoint- Returns:
- the number of edges
-
getNumEdges
public long getNumEdges()Description copied from interface:MultiEdges
Obtains the number of edges- Specified by:
getNumEdges
in interfaceMultiEdges
- Returns:
- the number of edges
-
getIncidentCount
public int getIncidentCount(int dest)Description copied from interface:MultiEdges
Gets the number of incident edges to a node- Specified by:
getIncidentCount
in interfaceMultiEdges
- Parameters:
dest
- Destiny node- Returns:
- the number of incident edges
-
getAdjacentCount
public int getAdjacentCount(int dest)Description copied from interface:MultiEdges
Gets the number of adjacent edges to a node- Specified by:
getAdjacentCount
in interfaceMultiEdges
- Parameters:
dest
- Origin node- Returns:
- the number of adjacent edges
-
getIsolatedNodes
public java.util.stream.IntStream getIsolatedNodes()Description copied from interface:MultiEdges
Obtains the set of nodes which do not have any neighbor.- Specified by:
getIsolatedNodes
in interfaceMultiEdges
- Returns:
- a stream containing the set of nodes which do not have neighbors.
-
hasAdjacentEdges
public boolean hasAdjacentEdges(int node)Description copied from interface:MultiEdges
Checks if a node has adjacent edges.- Specified by:
hasAdjacentEdges
in interfaceMultiEdges
- Parameters:
node
- the identifier of the node- Returns:
- true if it has adjacent edges, false otherwise
-
hasIncidentEdges
public boolean hasIncidentEdges(int node)Description copied from interface:MultiEdges
Checks if a node has incident edges.- Specified by:
hasIncidentEdges
in interfaceMultiEdges
- Parameters:
node
- the identifier of the node- Returns:
- true if it has incident edges, false otherwise
-
hasEdges
public boolean hasEdges(int node)Description copied from interface:MultiEdges
Checks if a node has adjacent or incident edges.- Specified by:
hasEdges
in interfaceMultiEdges
- Parameters:
node
- the identifier of the node- Returns:
- true if it has adjacent or incident edges, false otherwise
-
hasMutualEdges
public boolean hasMutualEdges(int node)Description copied from interface:MultiEdges
Checks if a node has mutual edges.- Specified by:
hasMutualEdges
in interfaceMultiEdges
- Parameters:
node
- the identifier of the node- Returns:
- true if it has mutual edges, false otherwise
-