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);
}
Beispiel #2
0
void FastMultipoleMultilevelEmbedder::call(GraphAttributes &GA)
{
	EdgeArray<float> edgeLengthAuto(GA.constGraph());
	computeAutoEdgeLength(GA, edgeLengthAuto);
	const Graph& t = GA.constGraph();
	if (t.numberOfNodes() <= 25)
	{
		FastMultipoleEmbedder fme;
		fme.setNumberOfThreads(this->m_iMaxNumThreads);
		fme.setRandomize(true);
		fme.setNumIterations(500);
		fme.call(GA);
		return;
	}

	run(GA, edgeLengthAuto);

	for(edge e : GA.constGraph().edges)
	{
		GA.bends(e).clear();
	}
}
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);
}
Beispiel #4
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;
}