Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Induced Subgraphs and Cliques

Provides functions dealing with induced subgraphs and finding cliques. More...

Classes

class  ogdf::CliqueFinderHeuristic
 Finds cliques and dense subgraphs using a heuristic. More...
 
class  ogdf::CliqueFinderModule
 Finds cliques. More...
 
class  ogdf::CliqueFinderSPQR
 Finds cliques using SPQR trees. More...
 

Functions

bool ogdf::maximumDensitySubgraph (Graph &G, NodeSet< true > &subgraphNodes, std::function< node(node)> resultNodeMap=[](node v) { return v;}, int64_t timelimit=-1)
 Calculates the maximum density subgraph of G. More...
 

Detailed Description

Provides functions dealing with induced subgraphs and finding cliques.

Function Documentation

◆ maximumDensitySubgraph()

bool ogdf::maximumDensitySubgraph ( Graph G,
NodeSet< true > &  subgraphNodes,
std::function< node(node)>  resultNodeMap = [](node v) { return v;},
int64_t  timelimit = -1 
)

Calculates the maximum density subgraph of G.

Returns the subgraph of G given by the nodes of the subgraph. The subgraph with the highest density, which is \(\frac{|E|}{|V|}\) of the subgraph, is returned. The graph is treated as undirected and unweighted.

The algorithm is based on: A. V. Goldberg. Finding a maximum density subgraph. EECS Department, University of California, Berkeley. Technical Report No. UCB/CSD-84-171, 1984. https://www2.eecs.berkeley.edu/Pubs/TechRpts/1984/CSD-84-171.pdf

Internally, the MinSTCutMaxFlow algorithm (using MaxFlowGoldbergTarjan) is called \(\mathcal{O}(\log n)\) times. Assuming a runtime of \(\mathcal{O}(mn^2)\) for the min cut algorithm, the overall runtime is \(\mathcal{O}(mn^2\log n)\).

Side Effect
Note that the input graph G is modified. If this is not wanted, use a GraphCopy or GraphCopySimple.
resultNodeMap
resultNodeMap can be used if subgraphNodes does not belong to G. This helps when passing in a GraphCopy or GraphCopySimple:
NodeSet<true> subgraphNodes(G);
GraphCopySimple GC(G);
maximumDensitySubgraph(GC, subgraphNodes, [&](node n){ return GC.original(n);});
Parameters
Gis the input graph.
subgraphNodesis the set of nodes inducing the subgraph.
resultNodeMapmaps each subgraph node (nodes of G) to some other node
timelimitset to a value greater than -1 to set a timelimit in milliseconds. Note that 0 is a valid timelimit. When encountering a timelimit there is no valid result.
Returns
true, if the algorithm was successful and did not run into a timeout.
ogdf::maximumDensitySubgraph
bool maximumDensitySubgraph(Graph &G, NodeSet< true > &subgraphNodes, std::function< node(node)> resultNodeMap=[](node v) { return v;}, int64_t timelimit=-1)
Calculates the maximum density subgraph of G.
ogdf::node
NodeElement * node
The type of nodes.
Definition: Graph_d.h:63