public class GraphUtils
extends Object
Auxiliary static methods to work with graphs.
These methods make intensive use of several Java libraries (i.e. JOM, JGraphT or JUNG) hiding low-level details to users.
Modifier and Type | Class and Description |
---|---|
static class |
GraphUtils.ClosedCycleRoutingException
Exception thrown when hop-by-hop routing includes closed cycles.
|
static class |
GraphUtils.GraphPath<E>
Class to represent a path in a Graph.
|
static class |
GraphUtils.JGraphTUtils
Auxiliary class to work with the graph library JGraphT.
|
static class |
GraphUtils.JUNGUtils
Auxiliary class to work with the graph library JUNG.
|
static class |
GraphUtils.SuurballeTarjanAlgorithm<V,E>
Class to calculate the shortest link-disjoint path pair between two nodes
using Suurballe-Tarjan's algorithm.
|
static class |
GraphUtils.YenAlgorithm<V,E>
Class to calculate the (loopless) k-shortest paths between a node
pair using Yen's algorithm.
|
Modifier and Type | Method and Description |
---|---|
static void |
checkRouteContinuity(Map<Long,Pair<Long,Long>> linkMap,
List<Long> seqLinks,
Constants.CheckRoutingCycleType checkCycles)
Checks for validity of a given path (continuity and, optionally, no loops).
|
static double |
computeEuclideanDistance(Point2D point1,
Point2D point2)
Computes the Euclidean distance between two points.
|
static double |
computeHaversineDistanceInKm(Point2D point1,
Point2D point2)
Computes the Haversine distance between two points, that is, the shortest
distance over the Earth's surface.
|
static double |
computeRoadDistanceInKm(double airlineDistanceInKm)
Applies a correction to a given airline distance (i.e.
|
static Quadruple<Map<Pair<Long,Long>,Double>,Double,Map<Long,Double>,Constants.RoutingCycleType> |
convert_fde2xde(long demandId,
Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Pair<Long,Long>> demandMap,
Map<Long,Double> h_d,
Map<Pair<Long,Long>,Double> f_de)
Given a forwarding rule mapping (fractions of traffic entering a node from
demand 'd', leaving that node through link 'e'), and an offered
traffic to the network, it generates the resulting demand-link routing in
the form x_de (amount of traffic from demand d, transmitted through link e),
only for a given demand.
|
static Quadruple<cern.colt.matrix.tdouble.DoubleMatrix2D,double[],double[],Constants.RoutingCycleType[]> |
convert_fde2xde(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Pair<Long,Long>> demandMap,
Map<Long,Double> h_d,
cern.colt.matrix.tdouble.DoubleMatrix2D f_de)
Given a forwarding rule mapping (fractions of traffic entering a node from
demand 'd', leaving that node through link 'e'), and an offered
traffic to the network, it generates the resulting demand-link routing in
the form x_de (amount of traffic from demand d, transmitted through link e).
|
static Quadruple<Map<Pair<Long,Long>,Double>,Map<Long,Double>,Map<Long,Double>,List<Constants.RoutingCycleType>> |
convert_fde2xde(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Pair<Long,Long>> demandMap,
Map<Long,Double> h_d,
Map<Pair<Long,Long>,Double> f_de)
Given a forwarding rule mapping (fractions of traffic entering a node from
demand 'd', leaving that node through link 'e'), and an offered
traffic to the network, it generates the resulting demand-link routing in
the form x_de (amount of traffic from demand d, transmitted through link e).
|
static Map<Pair<Long,Long>,Double> |
convert_fte2fde(Map<Long,Pair<Long,Long>> demandMap,
Map<Pair<Long,Long>,Double> f_te)
Given a destination-based routing in the form f_te (fractions of traffic in
a node, that is forwarded through each of its output links), it generates
the resulting demand-link routing in the form f_de (fractions of traffic in
a node from demand d, transmitted through link e).
|
static cern.colt.matrix.tdouble.DoubleMatrix2D |
convert_fte2fde(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> demandMap,
cern.colt.matrix.tdouble.DoubleMatrix2D f_te)
Given a destination-based routing in the form f_te (fractions of traffic in
a node, that is forwarded through each of its output links), it generates
the resulting demand-link routing in the form f_de (fractions of traffic in
a node from demand d, transmitted through link e).
|
static Quadruple<Map<Pair<Long,Long>,Double>,Map<Long,Double>,Map<Long,Double>,List<Constants.RoutingCycleType>> |
convert_fte2xde(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Pair<Long,Long>> demandMap,
Map<Long,Double> h_d,
Map<Pair<Long,Long>,Double> f_te)
Given a destination-based routing in the form f_te (fractions of traffic in
a node, that is forwarded through each of its output links), and an offered
traffic to the network, it generates the resulting demand-link routing in
the form x_de (amount of traffic from demand d, transmitted through link e).
|
static void |
convert_fte2xp(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Pair<Long,Long>> demandMap,
Map<Long,Double> h_d,
cern.colt.matrix.tdouble.DoubleMatrix2D f_te,
List<Long> d_p,
List<Double> x_p,
List<List<Long>> pathList)
Given a destination-based routing in the form f_te (fractions of traffic in a node, that is forwarded through each of its output links), and
an offered traffic to the network, it generates the resulting set of paths that are produced.
|
static void |
convert_fte2xp(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Pair<Long,Long>> demandMap,
Map<Long,Double> h_d,
Map<Pair<Long,Long>,Double> f_te,
List<Long> d_p,
List<Double> x_p,
List<List<Long>> pathList)
Given a destination-based routing in the form f_te (fractions of traffic in a node, that is forwarded through each of its output links), and
an offered traffic to the network, it generates the resulting set of paths that are produced.
|
static Quadruple<cern.colt.matrix.tdouble.DoubleMatrix2D,double[],double[],Constants.RoutingCycleType[]> |
convert_fte2xte(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap,
cern.colt.matrix.tdouble.DoubleMatrix2D f_te,
cern.colt.matrix.tdouble.DoubleMatrix2D trafficMatrix)
Given a destination-based routing in the form f_te (fractions of traffic in a node, that is forwarded through each of its output links), and
an offered traffic to the network, it generates the resulting destination-based
routing in the form x_te (amount of traffic targeted to node t, transmitted through link e).
|
static Quadruple<Map<Pair<Long,Long>,Double>,Map<Long,Double>,Map<Long,Double>,List<Constants.RoutingCycleType>> |
convert_fte2xte(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap,
Map<Pair<Long,Long>,Double> f_te,
cern.colt.matrix.tdouble.DoubleMatrix2D trafficMatrix)
Given a destination-based routing in the form f_te (fractions of traffic in a node, that is forwarded through each of its output links), and
an offered traffic to the network, it generates the resulting destination-based
routing in the form x_te (amount of traffic targeted to node t, transmitted through link e).
|
static Map<Pair<Long,Long>,Double> |
convert_xde2fde(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap,
Set<Long> demandIds,
Map<Pair<Long,Long>,Double> x_de)
Given a demand-link routing in the form x_de (amount of traffic from demand
d, transmitted through link e), returns the equivalent forwarding rule
mapping (fractions of traffic entering a node from demand 'd', leaving that
node through link 'e').
|
static int |
convert_xde2xp(Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Pair<Long,Long>> demandMap,
cern.colt.matrix.tdouble.DoubleMatrix2D x_de,
List<Long> d_p,
List<Double> x_p,
List<List<Long>> pathList)
Given the amount of traffic for each demand d and traversing link e, it computes
the equivalent path-based routing.
|
static int |
convert_xde2xp(Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Pair<Long,Long>> demandMap,
Map<Pair<Long,Long>,Double> x_de,
List<Long> d_p,
List<Double> x_p,
List<List<Long>> pathList)
Given the amount of traffic for each demand d and traversing link e, it computes
the equivalent path-based routing.
|
static double[] |
convert_xde2ye(cern.colt.matrix.tdouble.DoubleMatrix2D x_de)
Returns the carried traffic per link.
|
static Map<Long,Double> |
convert_xde2ye(Set<Long> linkIds,
Map<Pair<Long,Long>,Double> x_de)
Returns the carried traffic per link.
|
static cern.colt.matrix.tdouble.DoubleMatrix2D |
convert_xp2fte(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Pair<Long,Long>> demandMap,
Map<Long,Long> d_p,
Map<Long,Double> x_p,
Map<Long,List<Long>> pathList)
Given a set of traffic routes and their carried traffic returns a destination-based
routing in the form fte (fractions of traffic in a node, that is forwarded
through each of its output links).
|
static Map<Pair<Long,Long>,Double> |
convert_xp2xde(Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Long> d_p,
Map<Long,Double> x_p,
Map<Long,List<Long>> pathMap)
Given a path-based routing, returns the amount of traffic for each demand d
traversing each link e.
|
static cern.colt.matrix.tdouble.DoubleMatrix2D |
convert_xp2xde(Map<Long,Pair<Long,Long>> linkMap,
Set<Long> demandIds,
Map<Long,Long> d_p,
Map<Long,Double> x_p,
Map<Long,List<Long>> pathMap)
Given a path-based routing, returns the amount of traffic for each demand d
traversing each link e.
|
static cern.colt.matrix.tdouble.DoubleMatrix2D |
convert_xp2xte(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Pair<Long,Long>> demandMap,
Map<Long,Long> d_p,
Map<Long,Double> x_p,
Map<Long,List<Long>> pathList)
Given a set of traffic routes and their carried traffic returns a destination-based
routing in the form x_te (amount of traffic targeted to node t, transmitted through link e).
|
static double[] |
convert_xp2ye(Map<Long,Pair<Long,Long>> linkMap,
double[] x_p,
List<List<Long>> pathList)
Returns the carried traffic per link.
|
static double[] |
convert_xp2ye(Map<Long,Pair<Long,Long>> linkMap,
List<Double> x_p,
List<List<Long>> pathList)
Returns the carried traffic per link.
|
static cern.colt.matrix.tdouble.DoubleMatrix2D |
convert_xte2fte(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap,
cern.colt.matrix.tdouble.DoubleMatrix2D x_te)
Given a destination-based routing in the form of an array x_te (amount of traffic targeted to node t, transmitted through link e), it
returns the associated destination-based routing in the form of fractions f_te (fraction of the traffic targeted to node t that arrives
(or is generated in) node a(e) (the initial node of link e), that is forwarded through link e).
|
static double[] |
convert_xte2ye(cern.colt.matrix.tdouble.DoubleMatrix2D x_te)
Returns the carried traffic per link.
|
static double |
convertPath2PathCost(List<Long> seqLinks,
Map<Long,Double> linkCostMap)
Returns the total cost for a given path, wjocj os equal to the sum of the cost of
each traversed link.
|
static List<Double> |
convertPathList2PathCost(List<List<Long>> pathList,
Map<Long,Double> linkCostMap)
Returns the total cost for a given a list of paths.
|
static List<Long> |
convertSequenceOfLinksToSequenceOfNodes(Map<Long,Pair<Long,Long>> linkMap,
List<Long> seqLinks)
Converts a given sequence of links to the corresponding sequence of nodes.
|
static cern.colt.matrix.tdouble.DoubleMatrix2D |
getAdjacencyMatrix(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap)
Given a map of links, it computes the adjacency matrix.
|
static List<List<Long>> |
getAllLooplessShortestPaths(Map<Long,Pair<Long,Long>> linkMap,
long originNodeId,
long destinationNodeId,
Map<Long,Double> linkCostMap)
Returns all the loopless shortest paths between two nodes.
|
static cern.colt.matrix.tdouble.DoubleMatrix2D |
getBidirectionalMatrix(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap)
Given a map of links representing a bidirectional topology, with the same number
of links on each direction for each node pair, it bundles into opposite link
pairs and computes the bidirectional matrix.
|
static List<Long> |
getCapacitatedShortestPath(Map<Long,Pair<Long,Long>> linkMap,
long originNodeId,
long destinationNodeId,
Map<Long,Double> linkCostMap,
Map<Long,Double> linkSpareCapacityMap,
double capacityGoal)
Returns the shortest path that fulfills a given minimum capacity requirement
along its traversed links.
|
static cern.colt.matrix.tdouble.DoubleMatrix2D |
getIncidenceMatrix(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap)
Given a map of links, it computes the node-link incidence matrix.
|
static cern.colt.matrix.tdouble.DoubleMatrix2D |
getIncomingIncidenceMatrix(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap)
Given a map of links, it computes the node-link incoming incidence
matrix.
|
static List<List<Long>> |
getKLooplessShortestPaths(Map<Long,Pair<Long,Long>> linkMap,
long originNodeId,
long destinationNodeId,
int K,
Map<Long,Double> linkCostMap)
Returns the K-loopless shortest paths between two nodes.
|
static Set<Long> |
getNodeIncomingLinks(Map<Long,Pair<Long,Long>> linkMap,
long nodeId)
Given a link map and a node, it returns the set of links that enter to that node.
|
static Set<Long> |
getNodeOutgoingLinks(Map<Long,Pair<Long,Long>> linkMap,
long nodeId)
Given a link map and a node, it returns the set of links that leave that node.
|
static cern.colt.matrix.tdouble.DoubleMatrix2D |
getOutgoingIncidenceMatrix(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap)
Given a map of links, it computes the node-link outgoing incidence matrix.
|
static List<Long> |
getShortestPath(Map<Long,Pair<Long,Long>> linkMap,
long originNodeId,
long destinationNodeId,
Map<Long,Double> linkCostMap)
Obtains the sequence of links representing the (unidirectional) shortest path between two nodes.
|
static List<List<Long>> |
getTwoLinkDisjointPaths(Map<Long,Pair<Long,Long>> linkMap,
long originNodeId,
long destinationNodeId,
Map<Long,Double> linkCostMap)
Returns the shortest pair of link-disjoint paths, where each item represents a path.
|
static List<List<Long>> |
getTwoNodeDisjointPaths(Map<Long,Pair<Long,Long>> linkMap,
long originNodeId,
long destinationNodeId,
Map<Long,Double> linkCostMap)
Returns the shortest pair of node-disjoint paths, where each item represents a path.
|
static boolean |
isBidirectional(Map<Long,Pair<Long,Long>> linkMap)
Checks whether the physical topology has the same number of links between each node pair in both directions (assuming multi-digraphs).
|
static boolean |
isConnected(Set<Long> nodeIds,
Map<Long,Pair<Long,Long>> linkMap)
Check whether the physical topology is connected, that is, if it is possible
to connect every node to each other, but only in a subset of nodes (subgraph).
|
static boolean |
isSimple(Map<Long,Pair<Long,Long>> linkMap)
Check whether the physical topology is simple, that is, if it has at most one unidirectional link from a node to each other.
|
static boolean |
isWeightedBidirectional(Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Double> linkCostMap)
Checks whether the physical topology has the same number of links between each node pair in both directions (assuming multi-digraphs) and same weights per direction.
|
static Map<Long,Pair<Long,Long>> |
simplifyLinkMap(Map<Long,Pair<Long,Long>> linkMap,
Map<Long,Double> linkCostMap)
Given a link map that may contain multiple links between some node pairs,
returns a new link map where only appears, for each node pair, the link having
the lowest weight (links whose weight is equal to
Double.MAX_VALUE
are excluded). |
public static void checkRouteContinuity(Map<Long,Pair<Long,Long>> linkMap, List<Long> seqLinks, Constants.CheckRoutingCycleType checkCycles)
Checks for validity of a given path (continuity and, optionally, no loops).
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectseqLinks
- Sequence of traversed linkscheckCycles
- Indicates whether (and how) or not to check if there are cyclespublic static double computeEuclideanDistance(Point2D point1, Point2D point2)
point1
- Point 1point2
- Point 2public static double computeHaversineDistanceInKm(Point2D point1, Point2D point2)
Important: It is assumed an Earth's radius equal to Constants.EARTH_RADIUS_IN_KM
Important: Coordinates are assumed to be given in degress, conversions to radians are made internally.
point1
- Point 1 (x-coord is equal to longitude, y-coord is equal to latitude)point2
- Point 2 (x-coord is equal to longitude, y-coord is equal to latitude)public static double computeRoadDistanceInKm(double airlineDistanceInKm)
airlineDistanceInKm
- Airline distance in km (i.e. Euclidean distance, Haversine distance...)public static Quadruple<Map<Pair<Long,Long>,Double>,Double,Map<Long,Double>,Constants.RoutingCycleType> convert_fde2xde(long demandId, Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap, Map<Long,Pair<Long,Long>> demandMap, Map<Long,Double> h_d, Map<Pair<Long,Long>,Double> f_de)
demandId
- Demand identiifernodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectdemandMap
- Map of demands, where the key is the unique demand identifier and the value is a Pair
representing the ingress node and the egress node of the demand, respectively. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objecth_d
- The amount of traffic offered for each demandf_de
- For each demand-outgoing link pair sets the fraction of the traffic from demand d that arrives (or is generated in) node a(e) (the origin node of link e), that is forwarded through link e. It must hold that for every node n different of b(d), the sum of the fractions fde along its outgoing links must be lower or equal than 1 (unchecked)public static Quadruple<cern.colt.matrix.tdouble.DoubleMatrix2D,double[],double[],Constants.RoutingCycleType[]> convert_fde2xde(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap, Map<Long,Pair<Long,Long>> demandMap, Map<Long,Double> h_d, cern.colt.matrix.tdouble.DoubleMatrix2D f_de)
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectdemandMap
- Map of demands, where the key is the unique demand identifier and the value is a Pair
representing the ingress node and the egress node of the demand, respectively. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objecth_d
- The amount of traffic offered for each demandf_de
- For each demand d (d = 0 refers to the first demand in demandIds
, d = 1 refers to the second one, and so on), and each link e (e = 0 refers to the first link in linkMap.keySet()
, e = 1 refers to the second one, and so on), f_de[d][e]
sets the fraction of the traffic from demand d that arrives (or is generated in) node a(e) (the origin node of link e), that is forwarded through link e. It must hold that for every node n different of b(d), the sum of the fractions fde along its outgoing links must be lower or equal than 1 (unchecked)public static Quadruple<Map<Pair<Long,Long>,Double>,Map<Long,Double>,Map<Long,Double>,List<Constants.RoutingCycleType>> convert_fde2xde(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap, Map<Long,Pair<Long,Long>> demandMap, Map<Long,Double> h_d, Map<Pair<Long,Long>,Double> f_de)
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectdemandMap
- Map of demands, where the key is the unique demand identifier and the value is a Pair
representing the ingress node and the egress node of the demand, respectively. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objecth_d
- The amount of traffic offered for each demandf_de
- For each demand-outgoing link pair sets the fraction of the traffic from demand d that arrives (or is generated in) node a(e) (the origin node of link e), that is forwarded through link e. It must hold that for every node n different of b(d), the sum of the fractions fde along its outgoing links must be lower or equal than 1 (unchecked)public static Map<Pair<Long,Long>,Double> convert_fte2fde(Map<Long,Pair<Long,Long>> demandMap, Map<Pair<Long,Long>,Double> f_te)
demandMap
- Map of demands, where the key is the unique demand identifier and the value is a Pair
representing the ingress node and the egress node of the demand, respectively. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectf_te
- For each destination node t, and each link e, f_te[t][e]
sets the fraction of the traffic targeted to node t that arrives (or is generated in) node a(e) (the origin node of link e), that is forwarded through link e. It must hold that for every node n different of t, the sum of the fractions fte along its outgoing links must be lower or equal than 1 (unchecked)public static cern.colt.matrix.tdouble.DoubleMatrix2D convert_fte2fde(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> demandMap, cern.colt.matrix.tdouble.DoubleMatrix2D f_te)
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectdemandMap
- Map of demands, where the key is the unique demand identifier and the value is a Pair
representing the ingress node and the egress node of the demand, respectively. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectf_te
- For each destination node t (t = 0 refers to the first node in nodeIds
, t = 1 refers to the second one, and so on), and each link e (e = 0 refers to the first link in linkMap.keySet()
, e = 1 refers to the second one, and so on), f_te[t][e]
sets the fraction of the traffic targeted to node t that arrives (or is generated in) node a(e) (the origin node of link e), that is forwarded through link e. It must hold that for every node n different of t, the sum of the fractions fte along its outgoing links must be lower or equal than 1 (unchecked)public static Quadruple<Map<Pair<Long,Long>,Double>,Map<Long,Double>,Map<Long,Double>,List<Constants.RoutingCycleType>> convert_fte2xde(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap, Map<Long,Pair<Long,Long>> demandMap, Map<Long,Double> h_d, Map<Pair<Long,Long>,Double> f_te)
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectdemandMap
- Map of demands, where the key is the unique demand identifier and the value is a Pair
representing the ingress node and the egress node of the demand, respectively. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objecth_d
- The amount of traffic offered for each demandf_te
- For each destination node t and each link e, f_te[t][e]
sets the fraction of the traffic targeted to node t that arrives (or is generated in) node a(e) (the origin node of link e), that is forwarded through link e. It must hold that for every node n different of t, the sum of the fractions fte along its outgoing links must be lower or equal than 1 (unchecked)public static void convert_fte2xp(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap, Map<Long,Pair<Long,Long>> demandMap, Map<Long,Double> h_d, cern.colt.matrix.tdouble.DoubleMatrix2D f_te, List<Long> d_p, List<Double> x_p, List<List<Long>> pathList)
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectdemandMap
- Map of demands, where the key is the unique demand identifier and the value is a Pair
representing the ingress node and the egress node of the demand, respectively. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objecth_d
- The amount of traffic offered for each demandf_te
- For each destination node t (t = 0 refers to the first node in nodeIds
, t = 1 refers to the second one, and so on), and each link e (e = 0 refers to the first link in linkMap.keySet()
, e = 1 refers to the second one, and so on), f_te[t][e]
sets the fraction of the traffic targeted to node t that arrives (or is generated in) node a(e) (the origin node of link e), that is forwarded through link e. It must hold that for every node n different of t, the sum of the fractions fte along its outgoing links must be lower or equal than 1 (unchecked)d_p
- (Output parameter) Demand corresponding to each path. User should pass a initialized List
object (i.e. LinkedList
or ArrayList
)x_p
- (Output parameter) Carried traffic per path. User should pass a initialized List
object (i.e. LinkedList
or ArrayList
)pathList
- (Output parameter) List of paths, where each path is represented by its sequence of traversed links. User should pass a initialized List
object (i.e. LinkedList
or ArrayList
)public static void convert_fte2xp(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap, Map<Long,Pair<Long,Long>> demandMap, Map<Long,Double> h_d, Map<Pair<Long,Long>,Double> f_te, List<Long> d_p, List<Double> x_p, List<List<Long>> pathList)
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectdemandMap
- Map of demands, where the key is the unique demand identifier and the value is a Pair
representing the ingress node and the egress node of the demand, respectively. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objecth_d
- The amount of traffic offered for each demandf_te
- For each destination node t (t = 0 refers to the first node in nodeIds
, t = 1 refers to the second one, and so on), and each link e (e = 0 refers to the first link in linkMap.keySet()
, e = 1 refers to the second one, and so on), f_te[t][e]
sets the fraction of the traffic targeted to node t that arrives (or is generated in) node a(e) (the origin node of link e), that is forwarded through link e. It must hold that for every node n different of t, the sum of the fractions fte along its outgoing links must be lower or equal than 1 (unchecked)d_p
- (Output parameter) Demand corresponding to each path. User should pass a initialized List
object (i.e. LinkedList
or ArrayList
)x_p
- (Output parameter) Carried traffic per path. User should pass a initialized List
object (i.e. LinkedList
or ArrayList
)pathList
- (Output parameter) List of paths, where each path is represented by its sequence of traversed links. User should pass a initialized List
object (i.e. LinkedList
or ArrayList
)public static Quadruple<cern.colt.matrix.tdouble.DoubleMatrix2D,double[],double[],Constants.RoutingCycleType[]> convert_fte2xte(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap, cern.colt.matrix.tdouble.DoubleMatrix2D f_te, cern.colt.matrix.tdouble.DoubleMatrix2D trafficMatrix)
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectf_te
- For each destination node t (t = 0 refers to the first node in nodeIds
, t = 1 refers to the second one, and so on), and each link e (e = 0 refers to the first link in linkMap.keySet()
, e = 1 refers to the second one, and so on), f_te[t][e]
sets the fraction of the traffic targeted to node t that arrives (or is generated in) node a(e) (the origin node of link e), that is forwarded through link e. It must hold that for every node n different of t, the sum of the fractions fte along its outgoing links must be lower or equal than 1 (unchecked)trafficMatrix
- Traffic matrixpublic static Quadruple<Map<Pair<Long,Long>,Double>,Map<Long,Double>,Map<Long,Double>,List<Constants.RoutingCycleType>> convert_fte2xte(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap, Map<Pair<Long,Long>,Double> f_te, cern.colt.matrix.tdouble.DoubleMatrix2D trafficMatrix)
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectf_te
- For each destination node t and each link e, f_te[t][e]
sets the fraction of the traffic targeted to node t that arrives (or is generated in) node a(e) (the origin node of link e), that is forwarded through link e. It must hold that for every node n different of t, the sum of the fractions fte along its outgoing links must be lower or equal than 1 (unchecked)trafficMatrix
- Traffic matrixpublic static Map<Pair<Long,Long>,Double> convert_xde2fde(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap, Set<Long> demandIds, Map<Pair<Long,Long>,Double> x_de)
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectdemandIds
- Set of demand identifiers. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectx_de
- Demand-link routing in the form x_de (amount of traffic from demand d, transmitted through link e)public static int convert_xde2xp(Map<Long,Pair<Long,Long>> linkMap, Map<Long,Pair<Long,Long>> demandMap, cern.colt.matrix.tdouble.DoubleMatrix2D x_de, List<Long> d_p, List<Double> x_p, List<List<Long>> pathList)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectdemandMap
- Map of demands, where the key is the unique demand identifier and the value is a Pair
representing the ingress node and the egress node of the demand, respectively. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectx_de
- Matrix containing the amount of traffic from demand d (d = 0 refers to the first demand in demandMap.keySet()
, d = 1 refers to the second one, and so on) which traverses link e (e = 0 refers to the first link in linkMap.keySet()
, e = 1 refers to the second one, and so on)d_p
- (Output parameter) Demand corresponding to each path. User should pass a initialized List
object (i.e. LinkedList
or ArrayList
)x_p
- (Output parameter) Carried traffic per path. User should pass a initialized List
object (i.e. LinkedList
or ArrayList
)pathList
- (Output parameter) List of paths, where each path is represented by its sequence of traversed links. User should pass a initialized List
object (i.e. LinkedList
or ArrayList
)public static int convert_xde2xp(Map<Long,Pair<Long,Long>> linkMap, Map<Long,Pair<Long,Long>> demandMap, Map<Pair<Long,Long>,Double> x_de, List<Long> d_p, List<Double> x_p, List<List<Long>> pathList)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectdemandMap
- Map of demands, where the key is the unique demand identifier and the value is a Pair
representing the ingress node and the egress node of the demand, respectively. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectx_de
- Demand-link routing in the form x_de (amount of traffic from demand d, transmitted through link e)d_p
- (Output parameter) Demand corresponding to each path. User should pass a initialized List
object (i.e. LinkedList
or ArrayList
)x_p
- (Output parameter) Carried traffic per path. User should pass a initialized List
object (i.e. LinkedList
or ArrayList
)pathList
- (Output parameter) List of paths, where each path is represented by its sequence of traversed links. User should pass a initialized List
object (i.e. LinkedList
or ArrayList
)public static double[] convert_xde2ye(cern.colt.matrix.tdouble.DoubleMatrix2D x_de)
x_de
- Matrix containing the amount of traffic from demand d (d = 0 refers to the first demand in demandMap.keySet()
, d = 1 refers to the second one, and so on) which traverses link e (e = 0 refers to the first link in linkMap.keySet()
, e = 1 refers to the second one, and so on)public static Map<Long,Double> convert_xde2ye(Set<Long> linkIds, Map<Pair<Long,Long>,Double> x_de)
linkIds
- Set of link identifiers. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectx_de
- Demand-link routing in the form x_de (amount of traffic from demand d, transmitted through link e)public static cern.colt.matrix.tdouble.DoubleMatrix2D convert_xp2fte(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap, Map<Long,Pair<Long,Long>> demandMap, Map<Long,Long> d_p, Map<Long,Double> x_p, Map<Long,List<Long>> pathList)
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectdemandMap
- Map of demands, where the key is the unique demand identifier and the value is a Pair
representing the ingress node and the egress node of the demand, respectively. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectd_p
- Demand corresponding to each pathx_p
- Carried traffic per pathpathList
- List of paths, where each path is represented by its sequence of traversed linkspublic static Map<Pair<Long,Long>,Double> convert_xp2xde(Map<Long,Pair<Long,Long>> linkMap, Map<Long,Long> d_p, Map<Long,Double> x_p, Map<Long,List<Long>> pathMap)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectd_p
- Demand corresponding to each pathx_p
- Carried traffic per pathpathMap
- Map of paths, where the key is the unique path identifier and the value is the sequence of traversed linkspublic static cern.colt.matrix.tdouble.DoubleMatrix2D convert_xp2xde(Map<Long,Pair<Long,Long>> linkMap, Set<Long> demandIds, Map<Long,Long> d_p, Map<Long,Double> x_p, Map<Long,List<Long>> pathMap)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectdemandIds
- Set of demand identifiers. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectd_p
- Demand corresponding to each pathx_p
- Carried traffic per pathpathMap
- Map of paths, where the key is the unique path identifier and the value is the sequence of traversed linkspublic static cern.colt.matrix.tdouble.DoubleMatrix2D convert_xp2xte(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap, Map<Long,Pair<Long,Long>> demandMap, Map<Long,Long> d_p, Map<Long,Double> x_p, Map<Long,List<Long>> pathList)
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectdemandMap
- Map of demands, where the key is the unique demand identifier and the value is a Pair
representing the ingress node and the egress node of the demand, respectively. It is mandatory that can be iterated in ascending order of demand identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectd_p
- Demand corresponding to each pathx_p
- Carried traffic per pathpathList
- List of paths, where each path is represented by its sequence of traversed linkspublic static double[] convert_xp2ye(Map<Long,Pair<Long,Long>> linkMap, double[] x_p, List<List<Long>> pathList)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectx_p
- Carried traffic per pathpathList
- List of paths, where each path is represented by its sequence of traversed linkspublic static double[] convert_xp2ye(Map<Long,Pair<Long,Long>> linkMap, List<Double> x_p, List<List<Long>> pathList)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectx_p
- Carried traffic per pathpathList
- List of paths, where each path is represented by its sequence of traversed linkspublic static cern.colt.matrix.tdouble.DoubleMatrix2D convert_xte2fte(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap, cern.colt.matrix.tdouble.DoubleMatrix2D x_te)
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectx_te
- For each destination node t (t = 0 refers to the first node in nodeIds
, t = 1 refers to the second one, and so on), and each link e (e = 0 refers to the first link in linkMap.keySet()
, e = 1 refers to the second one, and so on), f_te[t][e]
represents the traffic targeted to node t that arrives (or is generated in) node a(e) (the origin node of link e), that is forwarded through link epublic static double[] convert_xte2ye(cern.colt.matrix.tdouble.DoubleMatrix2D x_te)
x_te
- For each destination node t (t = 0 refers to the first node in nodeIds
, t = 1 refers to the second one, and so on), and each link e (e = 0 refers to the first link in linkMap.keySet()
, e = 1 refers to the second one, and so on), f_te[t][e]
represents the traffic targeted to node t that arrives (or is generated in) node a(e) (the origin node of link e), that is forwarded through link epublic static double convertPath2PathCost(List<Long> seqLinks, Map<Long,Double> linkCostMap)
seqLinks
- Sequence of traversed linkslinkCostMap
- Cost per link (null means 'all one'), where the key is the link identifier and the value is the cost of traversing the link. No special iteration-order (i.e. ascending) is requiredpublic static List<Double> convertPathList2PathCost(List<List<Long>> pathList, Map<Long,Double> linkCostMap)
pathList
- List of paths, where each path is represented by its sequence of traversed linkslinkCostMap
- Cost per link, where the key is the link identifier and the value is the cost of traversing the link. No special iteration-order (i.e. ascending) is requiredpublic static List<Long> convertSequenceOfLinksToSequenceOfNodes(Map<Long,Pair<Long,Long>> linkMap, List<Long> seqLinks)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectseqLinks
- Sequence of traversed linkspublic static cern.colt.matrix.tdouble.DoubleMatrix2D getAdjacencyMatrix(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap)
Given a map of links, it computes the adjacency matrix. This is a matrix
with as many rows and columns as nodes. Position (i,j) accounts
for the number of links/demands/paths from node i (i = 0 refers
to the first node in nodeIds
, i = 1 refers to the second one,
and so on) to node j (j = 0 refers to the first node in
nodeIds
, j = 1 refers to the second one, and so on).
The output is in the sparse DoubleMatrix2D
format, so that could
be directly used along with the JOM library in order to
solve optimization problems.
For users not interested in this format, a classical dense double[][]
matrix could be obtained via the command:
double[][] matrix = getAdjacencyMatrix(nodeIds, linkMap).toArray();
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelypublic static List<List<Long>> getAllLooplessShortestPaths(Map<Long,Pair<Long,Long>> linkMap, long originNodeId, long destinationNodeId, Map<Long,Double> linkCostMap)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelyoriginNodeId
- Origin nodedestinationNodeId
- Destination nodelinkCostMap
- Cost per link, where the key is the link identifier and the value is the cost of traversing the link. No special iteration-order (i.e. ascending) is requiredpublic static cern.colt.matrix.tdouble.DoubleMatrix2D getBidirectionalMatrix(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap)
Given a map of links representing a bidirectional topology, with the same number
of links on each direction for each node pair, it bundles into opposite link
pairs and computes the bidirectional matrix. This is a matrix with as many
rows as opposite link pairs (or bidirectional links) and columns as links.
For each bidirectional link i, position (i,j) is equal
to 1 for link j (e = 0 refers to the first link in
linkMap.keySet()
, e = 1 refers to the second one, and so on)
in one direction, -1 for the link j in the opposite direction, and
zero otherwise. By convention, the selection order of links for each bidirectional link
is given by the following scheme: first, for each node i (in ascending order),
it iterates over all node j (in ascending order); then, for each node
pair (i, j) it retrieves the identifiers of links from i to j,
and viceversa. Finally, it adds a new row to the matrix for each bidirectional link
consisting of a link from i to j and another one in the
opposite direction (also, in ascending order).
The output is in the sparse DoubleMatrix2D
format, so
that could be directly used along with the JOM library
in order to solve optimization problems.
For users not interested in this format, a classical dense double[][]
matrix could be obtained via the command:
double[][] matrix = getBidirectionalMatrix(nodeIds, linkMap).toArray();
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectpublic static List<Long> getCapacitatedShortestPath(Map<Long,Pair<Long,Long>> linkMap, long originNodeId, long destinationNodeId, Map<Long,Double> linkCostMap, Map<Long,Double> linkSpareCapacityMap, double capacityGoal)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelyoriginNodeId
- Origin nodedestinationNodeId
- Destination nodelinkCostMap
- Cost per link, where the key is the link identifier and the value is the cost of traversing the link. No special iteration-order (i.e. ascending) is requiredlinkSpareCapacityMap
- Current available capacity per link, where the key is the link identifier and the value is the cost of traversing the link. No special iteration-order (i.e. ascending) is requiredcapacityGoal
- Minimum capacity requiredpublic static cern.colt.matrix.tdouble.DoubleMatrix2D getIncidenceMatrix(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap)
Given a map of links, it computes the node-link incidence matrix. This
is a matrix with as many rows as nodes, and as many columns as links.
Position (n, e) has a 1 if link e (e = 0 refers
to the first link in linkMap.keySet()
, e = 1 refers to the
second one, and so on) is initiated in node n (n = 0 refers
to the first node in nodeIds
, n = 1 refers to the second
one, and so on), -1 if it ends in node n, and 0 otherwise.
The output is in the sparse DoubleMatrix2D
format, so that could
be directly used along with the JOM library in order to
solve optimization problems.
For users not interested in this format, a classical dense double[][]
matrix could be obtained via the command:
double[][] matrix = getIncidenceMatrix(nodeIds, linkMap).toArray();
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectpublic static cern.colt.matrix.tdouble.DoubleMatrix2D getIncomingIncidenceMatrix(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap)
Given a map of links, it computes the node-link incoming incidence
matrix. This is a matrix with as many rows as nodes, and as many columns
as links. Position (n, e) has a 1 if link e
(e = 0 refers to the first link in linkMap.keySet()
,
e = 1 refers to the second one, and so on) is terminated in node
n (n = 0 refers to the first node in nodeIds
,
n = 1 refers to the second one, and so on), and 0 otherwise.
The output is in the sparse DoubleMatrix2D
format, so that could be directly used along with the JOM library in order to solve optimization problems.
For users not interested in this format, a classical dense double[][]
matrix could be obtained via the command:
double[][] matrix = getIncomingIncidenceMatrix(nodeIds, linkMap).toArray();
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectpublic static List<List<Long>> getKLooplessShortestPaths(Map<Long,Pair<Long,Long>> linkMap, long originNodeId, long destinationNodeId, int K, Map<Long,Double> linkCostMap)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectoriginNodeId
- Origin nodedestinationNodeId
- Destination nodeK
- Number of different pathslinkCostMap
- Cost per link, where the key is the link identifier and the value is the cost of traversing the link. No special iteration-order (i.e. ascending) is requiredpublic static Set<Long> getNodeIncomingLinks(Map<Long,Pair<Long,Long>> linkMap, long nodeId)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelynodeId
- Node identifierpublic static Set<Long> getNodeOutgoingLinks(Map<Long,Pair<Long,Long>> linkMap, long nodeId)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelynodeId
- Node identifierpublic static cern.colt.matrix.tdouble.DoubleMatrix2D getOutgoingIncidenceMatrix(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap)
Given a map of links, it computes the node-link outgoing incidence matrix.
This is a matrix with as many rows as nodes, and as many columns as links.
Position (n, e) has a 1 if link e (e = 0 refers
to the first link in linkMap.keySet()
, e = 1 refers to the
second one, and so on) is initiated in node n (n = 0 refers
to the first node in nodeIds
, n = 1 refers to the second
one, and so on), and 0 otherwise.
The output is in the sparse DoubleMatrix2D
format, so that could be directly used along with the JOM library in order to solve optimization problems.
For users not interested in this format, a classical dense double[][]
matrix could be obtained via the command:
double[][] matrix = getOutgoingIncidenceMatrix(nodeIds, linkMap).toArray();
nodeIds
- Set of node identifiers. It is mandatory that can be iterated in ascending order of node identifier (i.e. using TreeSet
or those Set
objects returned from Net2Plan
objectlinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectively. It is mandatory that can be iterated in ascending order of link identifier (i.e. using TreeMap
or those Map
objects returned from Net2Plan
objectpublic static List<Long> getShortestPath(Map<Long,Pair<Long,Long>> linkMap, long originNodeId, long destinationNodeId, Map<Long,Double> linkCostMap)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelyoriginNodeId
- Origin node identifierdestinationNodeId
- Destination node identifierlinkCostMap
- Cost per link, where the key is the link identifier and the value is the cost of traversing the link. No special iteration-order (i.e. ascending) is requiredpublic static List<List<Long>> getTwoLinkDisjointPaths(Map<Long,Pair<Long,Long>> linkMap, long originNodeId, long destinationNodeId, Map<Long,Double> linkCostMap)
size()
= 1, only one path was found; and when
size()
= 2, the link-disjoint paths were found. Internally it uses
the Suurballe-Tarjan algorithm.linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelyoriginNodeId
- Origin nodedestinationNodeId
- Destination nodelinkCostMap
- Cost per link, where the key is the link identifier and the value is the cost of traversing the link. No special iteration-order (i.e. ascending) is requiredpublic static List<List<Long>> getTwoNodeDisjointPaths(Map<Long,Pair<Long,Long>> linkMap, long originNodeId, long destinationNodeId, Map<Long,Double> linkCostMap)
size()
= 1, only one path was found; and when
size()
= 2, the node-disjoint paths were found. Internally it uses
the Suurballe-Tarjan algorithm.linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelyoriginNodeId
- Origin nodedestinationNodeId
- Destination nodelinkCostMap
- Cost per link, where the key is the link identifier and the value is the cost of traversing the link. No special iteration-order (i.e. ascending) is requiredpublic static boolean isBidirectional(Map<Long,Pair<Long,Long>> linkMap)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelytrue
if the physical topology is bidirectional, and false otherwisepublic static boolean isConnected(Set<Long> nodeIds, Map<Long,Pair<Long,Long>> linkMap)
nodeIds
- Set of node identifierslinkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelytrue
if the subgraph is connected, and false otherwisepublic static boolean isSimple(Map<Long,Pair<Long,Long>> linkMap)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelytrue
if the physical topology is simple, and false otherwisepublic static boolean isWeightedBidirectional(Map<Long,Pair<Long,Long>> linkMap, Map<Long,Double> linkCostMap)
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelylinkCostMap
- Cost per link, where the key is the link identifier and the value is the cost of traversing the link. No special iteration-order (i.e. ascending) is requiredtrue
if the physical topology is bidirectional and symmetric, and false otherwisepublic static Map<Long,Pair<Long,Long>> simplifyLinkMap(Map<Long,Pair<Long,Long>> linkMap, Map<Long,Double> linkCostMap)
Double.MAX_VALUE
are excluded). Ties are broken arbitrarely.
Important: Returned link map is not backed in the input one, so changes will not be reflected on it.
linkMap
- Map of links, where the key is the unique link identifier and the value is a Pair
representing the origin node and the destination node of the link, respectivelylinkCostMap
- Cost per link, where the key is the link identifier and the value is the cost of traversing the link. No special iteration-order (i.e. ascending) is required