本文整理匯總了Java中org.jgrapht.EdgeFactory類的典型用法代碼示例。如果您正苦於以下問題:Java EdgeFactory類的具體用法?Java EdgeFactory怎麽用?Java EdgeFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EdgeFactory類屬於org.jgrapht包,在下文中一共展示了EdgeFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: match
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
static KuhnMunkresMinimalWeightBipartitePerfectMatching<V, WeightedEdge>
match(final double[][] costMatrix, final int partitionCardinality) {
List<? extends V> first = firstPartition.subList(0, partitionCardinality);
List<? extends V> second = secondPartition.subList(0, partitionCardinality);
WeightedGraph<V, WeightedEdge> target =
new SimpleWeightedGraph<V, WeightedEdge>(new EdgeFactory<V, WeightedEdge>() {
@Override
public WeightedEdge createEdge(V sourceVertex, V targetVertex) {
return WeightedEdge.make(sourceVertex, targetVertex);
}
});
WeightedGraphGeneratorAdapter<V, WeightedEdge, V> generator =
new SimpleWeightedBipartiteGraphMatrixGenerator<V, WeightedEdge>()
.first (first)
.second (second)
.weights(costMatrix);
generator.generateGraph(target, null, null);
return new KuhnMunkresMinimalWeightBipartitePerfectMatching<V, WeightedEdge>(target, first, second);
}
開發者ID:j123b567,項目名稱:stack-usage,代碼行數:26,代碼來源:KuhnMunkresMinimalWeightBipartitePerfectMatchingTest.java
示例2: testAddEdgeWithMissingVertices
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
@Test
public void testAddEdgeWithMissingVertices() {
Graph<String, String> graph = new DefaultDirectedGraph<>(new EdgeFactory<String, String>() {
public String createEdge(String sourceVertex, String targetVertex) {
return sourceVertex + targetVertex;
};
});
graph = new AddVerticesAutomatically<>(graph);
graph.addEdge("A", "B");
graph.addEdge("A", "C", "DEF");
assertTrue(graph.containsVertex("A"));
assertTrue(graph.containsVertex("B"));
assertTrue(graph.containsVertex("C"));
assertTrue(graph.containsEdge("AB"));
assertTrue(graph.containsEdge("DEF"));
}
示例3: testCutCyclesCompleteGraph
import org.jgrapht.EdgeFactory; //導入依賴的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: BaseGraph
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
/**
* Construct a TestGraph with kmerSize
* @param kmerSize
*/
public BaseGraph(final int kmerSize, final EdgeFactory<V,E> edgeFactory) {
super(edgeFactory);
if ( kmerSize < 1 ) throw new IllegalArgumentException("kmerSize must be >= 1 but got " + kmerSize);
this.kmerSize = kmerSize;
}
示例5: TrafficLocationGraph
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
private TrafficLocationGraph()
{
EdgeFactory<Integer, LocationEdge> ef = new EdgeFactory<Integer, TrafficLocationGraph.LocationEdge>() {
@Override
public LocationEdge createEdge(Integer sourceVertex, Integer targetVertex) {
// TODO Auto-generated method stub
return new LocationEdge(sourceVertex, targetVertex);
}
};
graph = new DefaultDirectedGraph<Integer, LocationEdge>(ef);
}
示例6: createMetricClosure
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
/**
* Computes the metric closure with a given set of vertices over a graph.
* @param originalGraph The Graph over which the metric closure should be computed.
* @param destinations A set of vertices which should exist in the metric closure.
* @return A Graph that uses MetricClosureEdgeAnnotations that store the paths in the original graph to allow later reconstruction.
*/
public static <T, E> DirectedWeightedPseudograph<T, MetricClosureEdge<T>> createMetricClosure(DirectedWeightedPseudograph<T, E> originalGraph, Set<T> destinations) {
DirectedWeightedPseudograph<T, MetricClosureEdge<T>> metricClosure = new DirectedWeightedPseudograph<>(new EdgeFactory<T, MetricClosureEdge<T>>() {
@Override
public MetricClosureEdge<T> createEdge(T sourceVertex, T targetVertex) {
return new MetricClosureEdge<>(new ArrayList<T>());
}
});
for (E edge : originalGraph.edgeSet()) {
T start = originalGraph.getEdgeSource(edge);
T end = originalGraph.getEdgeTarget(edge);
metricClosure.addVertex(start);
metricClosure.addVertex(end);
MetricClosureEdge<T> newEdge = metricClosure.addEdge(start, end);
double edgeWeight = originalGraph.getEdgeWeight(edge);
metricClosure.setEdgeWeight(newEdge, edgeWeight);
}
Set<T> removedVertices = new HashSet<T>(originalGraph.vertexSet());
removedVertices.removeAll(destinations);
for (T removedVertex : removedVertices) {
eliminateVertex(metricClosure, removedVertex);
}
return metricClosure;
}
示例7: TestDigraph
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
public TestDigraph(EdgeFactory<DiNode, DiEdge> arg0) {
super(arg0, true, true);
}
示例8: constructDirectedGraph
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
@SuppressWarnings("rawtypes")
private DirectedGraph<AbstractProject<?,?>, String> constructDirectedGraph(AbstractProject<?,?> root, Set<String> exclusions) {
final DirectedGraph<AbstractProject<?,?>, String> graph = new DefaultDirectedGraph<AbstractProject<?,?>, String>(
new EdgeFactory<AbstractProject<?,?>, String>() {
public String createEdge(AbstractProject<?,?> source, AbstractProject<?,?> target) {
return String.format("'%s' --> '%s'", source.getName(), target.getName());
}
});
final StringBuilder prettyPrinter = new StringBuilder(); // Used for printing the pipeline graph as an adjacency list matrix.
final Stack<AbstractProject<?,?>> stack = new Stack<AbstractProject<?,?>>();
graph.addVertex(root);
stack.push(root);
while (!stack.isEmpty()) {
final AbstractProject<?,?> p = stack.pop();
prettyPrinter.append(p.getName());
prettyPrinter.append(": {");
int index = 0;
final List<AbstractProject> children = p.getDownstreamProjects();
for (AbstractProject<?,?> child : children) {
if (!child.isDisabled() && !exclusions.contains(child.getName())) {
graph.addVertex(child);
graph.addEdge(p, child);
stack.push(child);
if (index > 0) {
prettyPrinter.append(", ");
}
prettyPrinter.append(child.getName());
index++;
}
}
prettyPrinter.append(String.format("}%n"));
}
if (verbose) {
LOGGER.log(Level.INFO, String.format("The build pipeline graph rooted at '%s':%n%s", root.getName(), prettyPrinter.toString()));
}
return graph;
}
開發者ID:johnnymongiat,項目名稱:pipeline-sink-trigger-plugin,代碼行數:41,代碼來源:BuildGraphPipelineSinkTrigger.java
示例9: getEdgeFactory
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
@Override
public EdgeFactory<Node, Triple> getEdgeFactory() {
return edgeFactory;
}
示例10: getEdgeFactory
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
@Override
public EdgeFactory<RDFNode, Statement> getEdgeFactory() {
return edgeFactory;
}
示例11: StandardGraph
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
public StandardGraph(EdgeFactory<V, E> edgeFactory)
{
super(edgeFactory);
}
示例12: getEdgeFactory
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
public EdgeFactory<State, Transition> getEdgeFactory() {
return delegate.getEdgeFactory();
}
示例13: GeneNetwork
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
GeneNetwork(EdgeFactory edgeFactory) {
super(edgeFactory);
}
示例14: SimpleGraph
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
protected SimpleGraph(EdgeFactory<String, String> ef, boolean allowMultipleEdges, boolean allowLoops) {
super(ef, allowMultipleEdges, allowLoops);
// TODO Auto-generated constructor stub
}
示例15: getEdgeFactory
import org.jgrapht.EdgeFactory; //導入依賴的package包/類
@Override
public EdgeFactory<Vertex, Edge> getEdgeFactory() {
// TODO Auto-generated method stub
return null;
}