Пример #1
0
int main(int argc, char **argv) {
	Graph g;
	GraphAttributes ga(g);
	if (!GraphIO::readGML(ga, g, "uk_Pack_Bary_EC_FRENC.gml"))
	{
		cerr << "Could not load Graph" << endl;
		return 1;
	}

	node v;
	forall_nodes(v, g)
	{
		ga.width(v) = ga.height(v) = 10.0;
	}

	MultilevelGraph mlg(ga);

	FastMultipoleEmbedder *fme = new ogdf::FastMultipoleEmbedder();
	fme->setNumIterations(1000);
	fme->setRandomize(false);

	LocalBiconnectedMerger *lbcm = new ogdf::LocalBiconnectedMerger();
	lbcm->setFactor(2.0);
	lbcm->setEdgeLengthAdjustment(0);

	BarycenterPlacer *bp = new ogdf::BarycenterPlacer();
	bp->weightedPositionPriority(true);

	ScalingLayout *sl = new ogdf::ScalingLayout();
	sl->setExtraScalingSteps(1);
	sl->setScaling(5.0, 10.0);
	sl->setScalingType(ogdf::ScalingLayout::st_relativeToDesiredLength);
	sl->setSecondaryLayout(fme);
	sl->setLayoutRepeats(1);

	ModularMultilevelMixer *mmm = new ModularMultilevelMixer;
	mmm->setLayoutRepeats(1);
	mmm->setLevelLayoutModule(sl);
	mmm->setInitialPlacer(bp);
	mmm->setMultilevelBuilder(lbcm);

	TileToRowsCCPacker *ttrccp = new TileToRowsCCPacker;
	ComponentSplitterLayout *cs = new ComponentSplitterLayout;
	cs->setPacker(ttrccp);
	cs->setLayoutModule(mmm);
	PreprocessorLayout ppl;
	ppl.setLayoutModule(cs);
	ppl.setRandomizePositions(true);

	ppl.call(mlg);

	mlg.exportAttributes(ga);

	GraphIO::writeGML(ga, "uk_Pack_Bary_EC_FRENC-mmmnotwist.gml");
}
Пример #2
0
int main(int argc, char **argv) {
	Graph g;
	GraphAttributes ga(g);
	if (!GraphIO::readGML(ga, g, "uk_Pack_Bary_EC_FRENC.gml"))
	{
		cerr << "Could not load Graph" << endl;
		return 1;
	}

	for (node v : g.nodes)
		ga.width(v) = ga.height(v) = 10.0;

	MultilevelGraph mlg(ga);

	FastMultipoleEmbedder *fme = new ogdf::FastMultipoleEmbedder();
	fme->setNumIterations(1000);
	fme->setRandomize(false);

	SolarMerger *sm = new ogdf::SolarMerger(false, false);

	SolarPlacer *sp = new ogdf::SolarPlacer();

	ScalingLayout *sl = new ogdf::ScalingLayout();
	sl->setExtraScalingSteps(0);
	sl->setScaling(2.0, 2.0);
	sl->setScalingType(ogdf::ScalingLayout::st_relativeToDrawing);
	sl->setSecondaryLayout(fme);
	sl->setLayoutRepeats(1);

	ModularMultilevelMixer *mmm = new ModularMultilevelMixer;
	mmm->setLayoutRepeats(1);
	mmm->setLevelLayoutModule(sl);
	mmm->setInitialPlacer(sp);
	mmm->setMultilevelBuilder(sm);

	TileToRowsCCPacker *ttrccp = new TileToRowsCCPacker;
	ComponentSplitterLayout *cd = new ComponentSplitterLayout;
	cd->setPacker(ttrccp);
	cd->setLayoutModule(mmm);
	PreprocessorLayout ppl;
	ppl.setLayoutModule(cd);
	ppl.setRandomizePositions(true);

	ppl.call(mlg);

	mlg.exportAttributes(ga);

	GraphIO::writeGML(ga, "uk_Pack_Bary_EC_FRENC-mmmfast.gml");
}
Пример #3
0
void MMMExampleNoTwistLayout::call(MultilevelGraph &MLG)
{
	// Fast Multipole Embedder
	FastMultipoleEmbedder * FME = new FastMultipoleEmbedder();
	FME->setNumIterations(1000);
	FME->setRandomize(false);

	// Local Biconnected Merger
	LocalBiconnectedMerger * LBCM = new LocalBiconnectedMerger();
	LBCM->setFactor(2.0);
	LBCM->setEdgeLengthAdjustment(0); // BEFORE (but arg is int!): LBCM->setEdgeLengthAdjustment(0.1);

	// Barycenter Placer with weighted Positions
	BarycenterPlacer * BP = new BarycenterPlacer();
	BP->weightedPositionPriority(true);

	// No Scaling
	ScalingLayout *SL = new ScalingLayout();
	SL->setExtraScalingSteps(1);
	SL->setScaling(5.0, 10.0);
	SL->setScalingType(ScalingLayout::st_relativeToDesiredLength);
	SL->setSecondaryLayout(FME);
	SL->setLayoutRepeats(1);

	ModularMultilevelMixer *MMM = new ModularMultilevelMixer;
	MMM->setLayoutRepeats(1);
//	MMM->setAllEdgeLenghts(5.0);
//	MMM->setAllNodeSizes(1.0);
	MMM->setLevelLayoutModule(SL);
	MMM->setInitialPlacer(BP);
	MMM->setMultilevelBuilder(LBCM);

	ComponentSplitterLayout *CS = new ComponentSplitterLayout;
	CS->setLayoutModule(MMM);
	PreprocessorLayout PPL;
	PPL.setLayoutModule(CS);
	PPL.setRandomizePositions(true);

	PPL.call(MLG);
}
Пример #4
0
void MMMExampleFastLayout::call(MultilevelGraph &MLG)
{
	// Fast Multipole Embedder
	FastMultipoleEmbedder *FME = new FastMultipoleEmbedder();
	FME->setNumIterations(1000);
	FME->setRandomize(false);

	// Solar Merger
	SolarMerger * SM = new SolarMerger(false, false);

	// Solar Placer
	SolarPlacer * SP = new SolarPlacer();

	// No Scaling
	ScalingLayout * SL = new ScalingLayout();
	SL->setExtraScalingSteps(0);
	SL->setScaling(2.0, 2.0);
	SL->setScalingType(ScalingLayout::st_relativeToDrawing);
	SL->setSecondaryLayout(FME);
	SL->setLayoutRepeats(1);

	ModularMultilevelMixer *MMM = new ModularMultilevelMixer;
	MMM->setLayoutRepeats(1);
//	MMM->setAllEdgeLenghts(5.0);
//	MMM->setAllNodeSizes(1.0);
	MMM->setLevelLayoutModule(SL);
	MMM->setInitialPlacer(SP);
	MMM->setMultilevelBuilder(SM);

	ComponentSplitterLayout *CS = new ComponentSplitterLayout;
	CS->setLayoutModule(MMM);
	PreprocessorLayout PPL;
	PPL.setLayoutModule(CS);
	PPL.setRandomizePositions(true);

	PPL.call(MLG);
}
Пример #5
0
int main(int argc, const char *argv[])
{
	if (argc != 2) {
		std::cout << "Usage: " << argv[0] << " (0|1|2)" << std::endl;
		return 255;
	}

	// We first declare a Graph G with GraphAttributes GA and load it from
	// the GML file sierpinski_04.gml.
	Graph g;
	GraphAttributes ga(g);
	if (!GraphIO::read(ga, g, "uk_Pack_Bary_EC_FRENC.gml", GraphIO::readGML)) {
		std::cerr << "Could not load Graph" << std::endl;
		return 1;
	}

	// We assign a width and height of 10.0 to each node.
	for (node v : g.nodes) {
		ga.width(v) = ga.height(v) = 10.0;
	}

	// Then we create a MultilevelGraph from the GraphAttributes.
	MultilevelGraph mlg(ga);

	// The FastMultipoleEmbedder is used for the single level layout.
	FastMultipoleEmbedder *fme = new FastMultipoleEmbedder();
	// It will use 1000 iterations at each level.
	fme->setNumIterations(1000);
	fme->setRandomize(false);

	// To minimize dispersion of the graph when more nodes are added, a
	// ScalingLayout can be used to scale up the graph on each level.
	ScalingLayout *sl = new ScalingLayout();
	sl->setLayoutRepeats(1);
	// The FastMultipoleEmbedder is nested into this ScalingLayout.
	sl->setSecondaryLayout(fme);

	// Set the merger and placer according to the wanted configuration.
	MultilevelBuilder *merger;
	InitialPlacer *placer;
	switch (argv[1][0]) {
	case 2:
		configureFastLayout(sl, merger, placer);
		break;
	case 1:
		configureNiceLayout(sl, merger, placer);
		break;
	default:
		configureNoTwistLayout(sl, merger, placer);
		break;
	}

	// Then the ModularMultilevelMixer is created.
	ModularMultilevelMixer *mmm = new ModularMultilevelMixer;
	mmm->setLayoutRepeats(1);
	// The single level layout, the placer and the merger are set.
	mmm->setLevelLayoutModule(sl);
	mmm->setInitialPlacer(placer);
	mmm->setMultilevelBuilder(merger);

	// Since energybased algorithms are not doing well for disconnected
	// graphs, the ComponentSplitterLayout is used to split the graph and
	// computation is done separately for each connected component.
	ComponentSplitterLayout *csl = new ComponentSplitterLayout;
	// The TileToRowsPacker merges these connected components after computation.
	TileToRowsCCPacker *ttrccp = new TileToRowsCCPacker;
	csl->setPacker(ttrccp);
	csl->setLayoutModule(mmm);

	// At last the PreprocessorLayout removes double edges and loops.
	PreprocessorLayout ppl;
	ppl.setLayoutModule(csl);
	ppl.setRandomizePositions(true);

	ppl.call(mlg);

	// After the computation the MultilevelGraph is exported to the
	// GraphAttributes and written to disk.
	mlg.exportAttributes(ga);
	GraphIO::write(ga, "output-multilevelmixer-.gml", GraphIO::writeGML);

	return 0;
}