Class FastEdges
java.lang.Object
es.uam.eps.ir.relison.graph.edges.fast.FastEdges
- All Implemented Interfaces:
Edges
- Direct Known Subclasses:
FastDirectedUnweightedEdges
,FastDirectedWeightedEdges
,FastUndirectedUnweightedEdges
,FastUndirectedWeightedEdges
public abstract class FastEdges extends java.lang.Object implements Edges
Abstract fast implementation of class Edges.
-
Field Summary
Fields Modifier and Type Field Description protected long
numEdges
Current number of edges.protected AutoRelation<java.lang.Integer>
types
Relation for storing the types of the edges.protected AutoRelation<java.lang.Double>
weights
Relation for storing the weights of the edges. -
Constructor Summary
Constructors Constructor Description FastEdges(AutoRelation<java.lang.Double> weights, AutoRelation<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.long
getAdjacentCount(int node)
Gets the number of adjacent nodes.int
getEdgeType(int orig, int dest)
Gets the type of an edge.double
getEdgeWeight(int orig, int dest)
Gets the weight of an edge.long
getIncidentCount(int node)
Gets the number of incident nodes.java.util.stream.IntStream
getIsolatedNodes()
Obtains the set of nodes which do not have any neighbor.long
getMutualCount(int node)
Gets the number of nodes which are, at the same time, adjacent and incident.long
getNeighbourCount(int node)
Gets the number of neighbour nodes.long
getNumEdges()
Obtains the number of edges in the graph.boolean
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.edges.Edges
addEdge, getAdjacentNodes, getAdjacentTypes, getAdjacentWeights, getIncidentNodes, getIncidentTypes, getIncidentWeights, getMutualAdjacentTypes, getMutualAdjacentWeights, getMutualIncidentTypes, getMutualIncidentWeights, getMutualNodes, getMutualTypes, getMutualWeights, getNeighbourNodes, getNeighbourTypes, getNeighbourWeights, getNodesWithAdjacentEdges, getNodesWithEdges, getNodesWithIncidentEdges, getNodesWithMutualEdges, removeEdge, removeNode, updateEdgeType, updateEdgeWeight
-
Field Details
-
Constructor Details
-
FastEdges
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:Edges
Checks if an edge exists.- Specified by:
containsEdge
in interfaceEdges
- Parameters:
orig
- The source endpoint.dest
- The incoming endpoint.- Returns:
- true if the edge exists, false if not.
-
getEdgeWeight
public double getEdgeWeight(int orig, int dest)Description copied from interface:Edges
Gets the weight of an edge.- Specified by:
getEdgeWeight
in interfaceEdges
- Parameters:
orig
- The source endpoint.dest
- The incoming endpoint.- Returns:
- the value if the edge exists, the default error value if not.
-
getEdgeType
public int getEdgeType(int orig, int dest)Description copied from interface:Edges
Gets the type of an edge.- Specified by:
getEdgeType
in interfaceEdges
- Parameters:
orig
- The source endpoint.dest
- The incoming endpoint.- Returns:
- the type if the edge exists, the default error value if not.
-
addUser
public boolean addUser(int node)Description copied from interface:Edges
Adds a user to the edges. -
getNumEdges
public long getNumEdges()Description copied from interface:Edges
Obtains the number of edges in the graph.- Specified by:
getNumEdges
in interfaceEdges
- Returns:
- the number of edges in the graph.
-
getIncidentCount
public long getIncidentCount(int node)Description copied from interface:Edges
Gets the number of incident nodes.- Specified by:
getIncidentCount
in interfaceEdges
- Parameters:
node
- The node.- Returns:
- the number of incident nodes.
-
getAdjacentCount
public long getAdjacentCount(int node)Description copied from interface:Edges
Gets the number of adjacent nodes.- Specified by:
getAdjacentCount
in interfaceEdges
- Parameters:
node
- The node.- Returns:
- the number of adjacent nodes.
-
getNeighbourCount
public long getNeighbourCount(int node)Description copied from interface:Edges
Gets the number of neighbour nodes.- Specified by:
getNeighbourCount
in interfaceEdges
- Parameters:
node
- The node.- Returns:
- the number of neighbour nodes.
-
getMutualCount
public long getMutualCount(int node)Description copied from interface:Edges
Gets the number of nodes which are, at the same time, adjacent and incident.- Specified by:
getMutualCount
in interfaceEdges
- Parameters:
node
- The node.- Returns:
- the number of mutual neighbors.
-
getIsolatedNodes
public java.util.stream.IntStream getIsolatedNodes()Description copied from interface:Edges
Obtains the set of nodes which do not have any neighbor.- Specified by:
getIsolatedNodes
in interfaceEdges
- Returns:
- a stream containing the set of nodes which do not have neighbors.
-
hasAdjacentEdges
public boolean hasAdjacentEdges(int node)Description copied from interface:Edges
Checks if a node has adjacent edges.- Specified by:
hasAdjacentEdges
in interfaceEdges
- 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:Edges
Checks if a node has incident edges.- Specified by:
hasIncidentEdges
in interfaceEdges
- 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:Edges
Checks if a node has adjacent or incident edges. -
hasMutualEdges
public boolean hasMutualEdges(int node)Description copied from interface:Edges
Checks if a node has mutual edges.- Specified by:
hasMutualEdges
in interfaceEdges
- Parameters:
node
- The identifier of the node.- Returns:
- true if it has mutual edges, false otherwise.
-