Class GoldbergMaximumDensitySubgraphAlgorithm<V,E>
- Type Parameters:
V
- Type of verticesE
- Type of edges
- All Implemented Interfaces:
MaximumDensitySubgraphAlgorithm<V,
E>
The basic concept is to construct a network that can be used to compute the maximum density subgraph using a binary search approach. See
GoldbergMaximumDensitySubgraphAlgorithmBase
for further details
This variant of the algorithm assumes the density of a positive real-weighted graph G=(V,E) to be
defined as \[\frac{\sum\limits_{e \in E} w(e)}{\left|{V}\right|}\] and sets the weights of the
network from GoldbergMaximumDensitySubgraphAlgorithmBase
as proposed in the above paper.
For this case the weights of the network must be chosen to be: \[c_{ij}=w(ij)\,\forall \{i,j\}\in
E\] \[c_{it}=m+2g-d_i\,\forall i \in V\] \[c_{si}=m\,\forall i \in V\] where $m=\left|{E}\right|$
and $d_i$ is the degree of vertex $i$.
All the math to prove the correctness of these weights is the same as in
GoldbergMaximumDensitySubgraphAlgorithmBase
.
Because the density is per definition guaranteed to be rational, the distance of 2 possible
solutions for the maximum density can't be smaller than $\frac{1}{W(W-1)}$. This means shrinking
the binary search interval to this size, the correct solution is found. The runtime can in this
case be given by $O(M(n,n+m)\log{W})$, where $M(n,m)$ is the runtime of the internally used
MinimumSTCutAlgorithm
and $W$ is the sum of all weights from $G$.
- Author:
- Andre Immig
-
Field Summary
Fields inherited from class org.jgrapht.alg.densesubgraph.GoldbergMaximumDensitySubgraphAlgorithmBase
graph, guess
-
Constructor Summary
ConstructorDescriptionConvenience constructor that uses PushRelabel as default MinimumSTCutAlgorithmGoldbergMaximumDensitySubgraphAlgorithm
(Graph<V, E> graph, V s, V t, double epsilon, Function<Graph<V, DefaultWeightedEdge>, MinimumSTCutAlgorithm<V, DefaultWeightedEdge>> algFactory) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected double
protected double
protected double
Getter for network weights of edges su for u in Vprotected double
Getter for network weights of edges ut for u in VMethods inherited from class org.jgrapht.alg.densesubgraph.GoldbergMaximumDensitySubgraphAlgorithmBase
calculateDensest, getDensity
-
Constructor Details
-
GoldbergMaximumDensitySubgraphAlgorithm
public GoldbergMaximumDensitySubgraphAlgorithm(Graph<V, E> graph, V s, V t, double epsilon, Function<Graph<V, DefaultWeightedEdge>, MinimumSTCutAlgorithm<V, DefaultWeightedEdge>> algFactory) Constructor- Parameters:
algFactory
- factory to construct the algorithm to usegraph
- input for computations
- additional source vertext
- additional target vertexepsilon
- to use for internal computation
-
GoldbergMaximumDensitySubgraphAlgorithm
Convenience constructor that uses PushRelabel as default MinimumSTCutAlgorithm- Parameters:
graph
- input for computations
- additional source vertext
- additional target vertexepsilon
- to use for internal computation
-
-
Method Details
-
getEdgeWeightFromSourceToVertex
Getter for network weights of edges su for u in V- Specified by:
getEdgeWeightFromSourceToVertex
in classGoldbergMaximumDensitySubgraphAlgorithmBase<V,
E> - Parameters:
v
- of V- Returns:
- weight of the edge
-
getEdgeWeightFromVertexToSink
Getter for network weights of edges ut for u in V- Specified by:
getEdgeWeightFromVertexToSink
in classGoldbergMaximumDensitySubgraphAlgorithmBase<V,
E> - Parameters:
v
- of V- Returns:
- weight of the edge
-
computeDensityNumerator
- Specified by:
computeDensityNumerator
in classGoldbergMaximumDensitySubgraphAlgorithmBase<V,
E> - Parameters:
g
- the graph to compute the numerator density from- Returns:
- numerator part of the density
-
computeDensityDenominator
- Specified by:
computeDensityDenominator
in classGoldbergMaximumDensitySubgraphAlgorithmBase<V,
E> - Parameters:
g
- the graph to compute the denominator density from- Returns:
- numerator part of the density
-