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 longnumEdgesCurrent number of edges.protected AutoRelation<java.lang.Integer>typesRelation for storing the types of the edges.protected AutoRelation<java.lang.Double>weightsRelation 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 booleanaddUser(int node)Adds a user to the edges.booleancontainsEdge(int orig, int dest)Checks if an edge exists.longgetAdjacentCount(int node)Gets the number of adjacent nodes.intgetEdgeType(int orig, int dest)Gets the type of an edge.doublegetEdgeWeight(int orig, int dest)Gets the weight of an edge.longgetIncidentCount(int node)Gets the number of incident nodes.java.util.stream.IntStreamgetIsolatedNodes()Obtains the set of nodes which do not have any neighbor.longgetMutualCount(int node)Gets the number of nodes which are, at the same time, adjacent and incident.longgetNeighbourCount(int node)Gets the number of neighbour nodes.longgetNumEdges()Obtains the number of edges in the graph.booleanhasAdjacentEdges(int node)Checks if a node has adjacent edges.booleanhasEdges(int node)Checks if a node has adjacent or incident edges.booleanhasIncidentEdges(int node)Checks if a node has incident edges.booleanhasMutualEdges(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, waitMethods 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:EdgesChecks if an edge exists.- Specified by:
containsEdgein 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:EdgesGets the weight of an edge.- Specified by:
getEdgeWeightin 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:EdgesGets the type of an edge.- Specified by:
getEdgeTypein 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:EdgesAdds a user to the edges. -
getNumEdges
public long getNumEdges()Description copied from interface:EdgesObtains the number of edges in the graph.- Specified by:
getNumEdgesin interfaceEdges- Returns:
- the number of edges in the graph.
-
getIncidentCount
public long getIncidentCount(int node)Description copied from interface:EdgesGets the number of incident nodes.- Specified by:
getIncidentCountin interfaceEdges- Parameters:
node- The node.- Returns:
- the number of incident nodes.
-
getAdjacentCount
public long getAdjacentCount(int node)Description copied from interface:EdgesGets the number of adjacent nodes.- Specified by:
getAdjacentCountin interfaceEdges- Parameters:
node- The node.- Returns:
- the number of adjacent nodes.
-
getNeighbourCount
public long getNeighbourCount(int node)Description copied from interface:EdgesGets the number of neighbour nodes.- Specified by:
getNeighbourCountin interfaceEdges- Parameters:
node- The node.- Returns:
- the number of neighbour nodes.
-
getMutualCount
public long getMutualCount(int node)Description copied from interface:EdgesGets the number of nodes which are, at the same time, adjacent and incident.- Specified by:
getMutualCountin interfaceEdges- Parameters:
node- The node.- Returns:
- the number of mutual neighbors.
-
getIsolatedNodes
public java.util.stream.IntStream getIsolatedNodes()Description copied from interface:EdgesObtains the set of nodes which do not have any neighbor.- Specified by:
getIsolatedNodesin interfaceEdges- Returns:
- a stream containing the set of nodes which do not have neighbors.
-
hasAdjacentEdges
public boolean hasAdjacentEdges(int node)Description copied from interface:EdgesChecks if a node has adjacent edges.- Specified by:
hasAdjacentEdgesin 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:EdgesChecks if a node has incident edges.- Specified by:
hasIncidentEdgesin 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:EdgesChecks if a node has adjacent or incident edges. -
hasMutualEdges
public boolean hasMutualEdges(int node)Description copied from interface:EdgesChecks if a node has mutual edges.- Specified by:
hasMutualEdgesin interfaceEdges- Parameters:
node- The identifier of the node.- Returns:
- true if it has mutual edges, false otherwise.
-