本文整理汇总了Java中org.jgrapht.VertexFactory类的典型用法代码示例。如果您正苦于以下问题:Java VertexFactory类的具体用法?Java VertexFactory怎么用?Java VertexFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VertexFactory类属于org.jgrapht包,在下文中一共展示了VertexFactory类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateCompleteGraph
import org.jgrapht.VertexFactory; //导入依赖的package包/类
private Graph<AutomatVertex, DefaultEdge> generateCompleteGraph(int size) {
LOG.info("--- generateCompleteGraph ---");
//Create the CompleteGraphGenerator object
final Graph<AutomatVertex, DefaultEdge> completeGraph = new SimpleGraph<>(DefaultEdge.class);
final CompleteGraphGenerator<AutomatVertex, DefaultEdge> completeGenerator = new CompleteGraphGenerator<>(size);
//Create the VertexFactory so the generator can create vertices
final VertexFactory<AutomatVertex> vFactory = new ClassBasedVertexFactory<>(AutomatVertex.class);
LOG.info("Generating complete graph");
//Use the CompleteGraphGenerator object to make completeGraph a
//complete graph with [size] number of vertices
completeGenerator.generateGraph(completeGraph, vFactory, null);
return completeGraph;
}
示例2: nonPlanarRandomGraphStructure
import org.jgrapht.VertexFactory; //导入依赖的package包/类
/**
* Creates a naive, random, not necessarily planar graph
*/
@Deprecated
public static UndirectedGraph<RegionSetup, DefaultEdge> nonPlanarRandomGraphStructure(
final double populationPerRegionMean,
final double populationStandardDeviation,
UniformDistributionRNG rng,
IntegerInterval numberOfRegionsInterval,
IntegerInterval averageAdjacenciesPerRegionInterval
) {
int numberOfRegions = rng.nextInt(numberOfRegionsInterval);
int numberOfAdjacencies = rng.nextInt(averageAdjacenciesPerRegionInterval) * numberOfRegions;
RandomGraphGenerator<RegionSetup, DefaultEdge> randomGraphGenerator = new RandomGraphGenerator<>(
numberOfRegions, numberOfAdjacencies, rng.nextLong());
SimpleGraph<RegionSetup, DefaultEdge> targetGraph = new SimpleGraph<>(DefaultEdge.class);
VertexFactory<RegionSetup> vertexFactory = () -> new RegionSetup(populationPerRegionMean, populationStandardDeviation, "randomly created");
randomGraphGenerator.generateGraph(targetGraph, vertexFactory, null);
return targetGraph;
}
示例3: testCutCyclesCompleteGraph
import org.jgrapht.VertexFactory; //导入依赖的package包/类
@Test
public void testCutCyclesCompleteGraph() throws IOException {
CompleteGraphGenerator<String, String> generator = new CompleteGraphGenerator<>(5);
DirectedGraph<String, String> graph = new DefaultDirectedGraph<>(new EdgeFactory<String, String>() {
@Override
public String createEdge(String sourceVertex, String targetVertex) {
return sourceVertex + targetVertex;
}
});
generator.generateGraph(graph, new VertexFactory<String>() {
private int count = 0;
@Override
public String createVertex() {
count ++;
return "V" + count;
}
}, new HashMap<String, String>());
DirectedGraph<String, String> target = new DefaultDirectedGraph<>(new UnsupportedEdgeFactory<String, String>());
target = new MinimumEdgesCycleCut<String, String>(graph, target).cutCycles();
}
示例4: generateGraph
import org.jgrapht.VertexFactory; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void generateGraph(
Graph<V, E> target,
VertexFactory<V> vertexFactory,
Map<String, V> resultMap)
{
final int size = readNodeCount();
if (resultMap == null) {
resultMap = new HashMap<>();
}
for (int i = 0; i < size; i++) {
V newVertex = vertexFactory.createVertex();
target.addVertex(newVertex);
resultMap.put(Integer.toString(i + 1), newVertex);
}
String[] cols = skipComments();
while (cols != null) {
if (cols[0].equals("e")) {
E edge = target
.addEdge(resultMap.get(cols[1]), resultMap.get(cols[2]));
if (target instanceof WeightedGraph && (edge != null)) {
double weight = defaultWeight;
if (cols.length > 3) {
weight = Double.parseDouble(cols[3]);
}
((WeightedGraph<V, E>) target).setEdgeWeight(edge, weight);
}
}
cols = skipComments();
}
}