本文整理汇总了Java中org.jgrapht.graph.SimpleDirectedGraph类的典型用法代码示例。如果您正苦于以下问题:Java SimpleDirectedGraph类的具体用法?Java SimpleDirectedGraph怎么用?Java SimpleDirectedGraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleDirectedGraph类属于org.jgrapht.graph包,在下文中一共展示了SimpleDirectedGraph类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: determineAndSolveConflicts
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
protected static void determineAndSolveConflicts(final PathBlockSet resultBlocks) {
// determine conflicts
final PathBlockSet deletedBlocks = new PathBlockSet();
final DirectedGraph<Block, BlockConflict> blockConflictGraph = new SimpleDirectedGraph<>(BlockConflict::of);
for (final Block block : resultBlocks.getBlocks()) {
blockConflictGraph.addVertex(block);
}
for (final Block x : blockConflictGraph.vertexSet()) {
createArcs(blockConflictGraph, resultBlocks, x);
}
// solve conflicts
while (true) {
final Optional<BlockConflict> mostUsefulConflictsFirst =
blockConflictGraph.edgeSet().stream().max(Comparator.comparingInt(BlockConflict::getQuality));
if (!mostUsefulConflictsFirst.isPresent()) {
break;
}
final BlockConflict blockConflict = mostUsefulConflictsFirst.get();
solveConflict(blockConflict, blockConflictGraph, resultBlocks, deletedBlocks);
}
}
开发者ID:RWTH-i5-IDSG,项目名称:jamocha,代码行数:22,代码来源:PathBlocks.java
示例2: loadGraph
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
* Read this ldap record,{@code cn=Hierarchies, ou=OS-P} into this entity, {@link Hier}, before loading into this collection class,{@code org.jgrapht.graph.SimpleDirectedGraph}
* using 3rd party lib, <a href="http://www.jgrapht.org/">JGraphT</a>.
*
* @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
* @return handle to simple digraph containing role hierarchies.
*/
private synchronized SimpleDirectedGraph<String, Relationship> loadGraph( String contextId )
{
Hier inHier = new Hier( Hier.Type.ROLE );
inHier.setContextId( contextId );
LOG.info( "loadGraph initializing ROLE context [{}]", inHier.getContextId() );
List<Graphable> descendants = null;
try
{
descendants = roleP.getAllDescendants( inHier.getContextId() );
}
catch ( SecurityException se )
{
LOG.info( "loadGraph caught SecurityException={}", se );
}
Hier hier = HierUtil.loadHier( contextId, descendants );
SimpleDirectedGraph<String, Relationship> graph;
graph = HierUtil.buildGraph( hier );
roleCache.put( getKey( contextId ), graph );
return graph;
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:32,代码来源:RoleUtil.java
示例3: getGraph
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
*
* @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
* @return handle to simple digraph containing role hierarchies.
*/
private SimpleDirectedGraph<String, Relationship> getGraph( String contextId )
{
String key = getKey( contextId );
LOG.debug("Getting graph for key " + contextId);
SimpleDirectedGraph<String, Relationship> graph = ( SimpleDirectedGraph<String, Relationship> ) roleCache
.get( key );
if(graph == null){
LOG.debug("Graph was null, creating... " + contextId);
return loadGraph( contextId );
}
else{
LOG.debug("Graph found in cache, returning...");
return graph;
}
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:23,代码来源:RoleUtil.java
示例4: toGraph
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
* This method converts from physical ldap entity format, {@link Hier} to logical {@code org.jgrapht.graph.SimpleDirectedGraph}.
*
* @param hier contains parent-child relationship in preparation to storing in ldap {@code ftRels} attribute of {@code ftHier} object class.
* @return {@code org.jgrapht.graph.SimpleDirectedGraph} containing the vertices of {@code String}, and edges, as {@link Relationship}s that correspond to relational data.
*/
private static SimpleDirectedGraph<String, Relationship> toGraph( Hier hier )
{
LOG.debug( "toGraph" );
SimpleDirectedGraph<String, Relationship> graph =
new SimpleDirectedGraph<>( Relationship.class );
List<Relationship> edges = hier.getRelationships();
if ( edges != null && edges.size() > 0 )
{
for ( Relationship edge : edges )
{
String child = edge.getChild();
String parent = edge.getParent();
try
{
graph.addVertex( child );
graph.addVertex( parent );
graph.addEdge( child, parent, edge );
}
catch (java.lang.IllegalArgumentException e)
{
String error = "toGraph child: " + child + " parent: " + parent + " caught IllegalArgumentException=" + e;
LOG.error( error );
}
LOG.debug( "toGraph child={}, parent={}", child, parent );
}
}
return graph;
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:37,代码来源:HierUtil.java
示例5: getParents
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
* Private utility to return the parents (direct ascendants) of a given child node.
*
* @param vertex contains node name and acts as cursor for current location.
* @param graph contains a reference to simple digraph {@code org.jgrapht.graph.SimpleDirectedGraph}.
* @return Set of names that are parents of given child.
*/
static Set<String> getParents( String vertex, SimpleDirectedGraph<String, Relationship> graph )
{
Set<String> parents = new HashSet<>();
if ( graph == null )
{
// graph is null
return null;
}
LOG.debug( "getParents [{}]", vertex);
Set<Relationship> edges;
try
{
edges = graph.outgoingEdgesOf( vertex );
}
catch ( java.lang.IllegalArgumentException iae )
{
// vertex is leaf.
return null;
}
for ( Relationship edge : edges )
{
parents.add( edge.getParent() );
}
return parents;
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:33,代码来源:HierUtil.java
示例6: buildGraph
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
* Method instantiates a new digraph, {@code org.jgrapht.graph.SimpleDirectedGraph}, using data passed in via
* {@link Hier} entity.
*
* @param hier contains the source data for digraph.
* @return reference to {@code org.jgrapht.graph.SimpleDirectedGraph}.
*/
static SimpleDirectedGraph<String, Relationship> buildGraph( Hier hier )
{
SimpleDirectedGraph<String, Relationship> graph;
LOG.debug( "buildGraph is initializing" );
if ( hier == null )
{
String error = "buildGraph detected null hier=";
LOG.error( error );
return null;
}
graph = toGraph( hier );
LOG.debug( "buildGraph success to toGraph" );
LOG.debug( "buildGraph is success" );
return graph;
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:23,代码来源:HierUtil.java
示例7: getGraph
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
* @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
* @return handle to simple digraph containing perm ou hierarchies.
*/
private SimpleDirectedGraph<String, Relationship> getGraph( String contextId )
{
String key = getKey( contextId );
LOG.debug("Getting graph for key " + contextId);
SimpleDirectedGraph<String, Relationship> graph = ( SimpleDirectedGraph<String, Relationship> ) psoCache
.get( key );
if(graph == null){
LOG.debug("Graph was null, creating... " + contextId);
return loadGraph( contextId );
}
else{
LOG.debug("Graph found in cache, returning...");
return graph;
}
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:22,代码来源:PsoUtil.java
示例8: getGraph
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
*
* @return handle to simple digraph containing user ou hierarchies.
*/
private SimpleDirectedGraph<String, Relationship> getGraph( String contextId )
{
String key = getKey( contextId );
LOG.debug("Getting graph for key " + contextId);
SimpleDirectedGraph<String, Relationship> graph = ( SimpleDirectedGraph<String, Relationship> ) usoCache
.get( key );
if(graph == null){
LOG.debug("Graph was null, creating... " + contextId);
return loadGraph( contextId );
}
else{
LOG.debug("Graph found in cache, returning...");
return graph;
}
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:22,代码来源:UsoUtil.java
示例9: loadGraph
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
* Read this ldap record,{@code cn=Hierarchies, ou=OS-P} into this entity, {@link Hier}, before loading into this collection class,{@code org.jgrapht.graph.SimpleDirectedGraph}
* using 3rd party lib, <a href="http://www.jgrapht.org/">JGraphT</a>.
*
* @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
* @return handle to simple digraph containing adminRole hierarchies.
*/
private static synchronized SimpleDirectedGraph<String, Relationship> loadGraph( String contextId )
{
Hier inHier = new Hier( Hier.Type.ROLE );
inHier.setContextId( contextId );
LOG.info( "loadGraph initializing ADMIN ROLE context [{}]", inHier.getContextId() );
List<Graphable> descendants = null;
try
{
descendants = adminRoleP.getAllDescendants( inHier.getContextId() );
}
catch ( SecurityException se )
{
LOG.info( "loadGraph caught SecurityException={}", se );
}
Hier hier = HierUtil.loadHier( contextId, descendants );
SimpleDirectedGraph<String, Relationship> graph;
graph = HierUtil.buildGraph( hier );
adminRoleCache.put( getKey( contextId ), graph );
return graph;
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:32,代码来源:AdminRoleUtil.java
示例10: getGraph
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
* Read this ldap record,{@code cn=Hierarchies, ou=OS-P} into this entity, {@link Hier}, before loading into this collection class,{@code org.jgrapht.graph.SimpleDirectedGraph}
* using 3rd party lib, <a href="http://www.jgrapht.org/">JGraphT</a>.
*
* @param contextId maps to sub-tree in DIT, e.g. ou=contextId, dc=example, dc=com.
* @return handle to simple digraph containing adminRole hierarchies.
*/
private static SimpleDirectedGraph<String, Relationship> getGraph( String contextId )
{
String key = getKey( contextId );
LOG.debug("Getting graph for key " + contextId);
SimpleDirectedGraph<String, Relationship> graph = ( SimpleDirectedGraph<String, Relationship> ) adminRoleCache
.get( key );
if(graph == null){
LOG.debug("Graph was null, creating... " + contextId);
return loadGraph( contextId );
}
else{
LOG.debug("Graph found in cache, returning...");
return graph;
}
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:25,代码来源:AdminRoleUtil.java
示例11: getSpeciesInHierarchicalOrder
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
private Iterable<SpeciesDescription> getSpeciesInHierarchicalOrder(final ModelDescription model) {
final DirectedGraph<SpeciesDescription, Object> hierarchy = new SimpleDirectedGraph<>(Object.class);
final DescriptionVisitor visitor = new DescriptionVisitor<SpeciesDescription>() {
@Override
public boolean visit(final SpeciesDescription desc) {
if (desc instanceof ModelDescription)
return true;
final SpeciesDescription sd = desc.getParent();
if (sd == null || sd == desc)
return false;
hierarchy.addVertex(desc);
if (!sd.isBuiltIn()) {
hierarchy.addVertex(sd);
hierarchy.addEdge(sd, desc);
}
return true;
}
};
model.visitAllSpecies(visitor);
return () -> new TopologicalOrderIterator<>(hierarchy);
}
开发者ID:gama-platform,项目名称:gama,代码行数:23,代码来源:ModelAssembler.java
示例12: sort
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
public List<String> sort(List<Class<?>> classes) throws OrderSortCycleException {
List<String> result = new ArrayList<>();
SimpleDirectedGraph<String, DefaultEdge> graph = new SimpleDirectedGraph<>(DefaultEdge.class);
for (OrderConstraint orderConstraint : getConstraints(classes)) {
graph.addVertex(orderConstraint.getFirst());
graph.addVertex(orderConstraint.getSecond());
graph.addEdge(orderConstraint.getFirst(), orderConstraint.getSecond());
}
CycleDetector<String, DefaultEdge> cycleDetector = new CycleDetector<>(graph);
if(!cycleDetector.detectCycles()) {
for (TopologicalOrderIterator<String, DefaultEdge> iterator = new TopologicalOrderIterator<>(graph); iterator.hasNext();) {
result.add(iterator.next());
}
} else {
String cycles = Joiner.on(", ").join(cycleDetector.findCycles());
throw new OrderSortCycleException("The given order constraints contain (at least one) cycle. Cycles can only "
+ "be caused by static references because we have single inherintance only in Java (involved classes: '" + cycles + "').");
}
return result;
}
开发者ID:janScheible,项目名称:knorxx,代码行数:26,代码来源:OrderSorter.java
示例13: checkDependencyCycles
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
* Check if there are any cycles in the dependencies of the modules.
*/
public void checkDependencyCycles(List<String> errors) {
if (!dependenciesResolved) {
throw new Error("Call resolveDependencies() first");
}
SimpleDirectedGraph<ModuleModel, Edge> g = buildModuleDependencyGraph();
CycleDetector<ModuleModel, Edge> detector = new CycleDetector<>(g);
Set<ModuleModel> cycleModules = detector.findCycles();
if (!cycleModules.isEmpty()) {
errors.add("Found cycle in module dependency graph. Involved modules: "
+ cycleModules);
}
}
开发者ID:ruediste,项目名称:jabsaw,代码行数:19,代码来源:ProjectModel.java
示例14: directedGraph
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
* Create a simple directed graph.
*
* @see http://en.wikipedia.org/wiki/Topological_sorting
*/
@SuppressWarnings("boxing")
public static DirectedGraph<Integer, DefaultEdge> directedGraph()
{
final DirectedGraph<Integer, DefaultEdge> g = new SimpleDirectedGraph<>(
DefaultEdge.class);
final Set<Integer> vertices = CollectionUtil.toSet(7, 5, 3, 11, 8, 2, 9, 10);
for (final Integer v : vertices)
{
g.addVertex(v);
}
g.addEdge(7, 8);
g.addEdge(7, 11);
g.addEdge(5, 11);
g.addEdge(3, 8);
g.addEdge(3, 10);
g.addEdge(11, 2);
g.addEdge(11, 9);
g.addEdge(11, 10);
g.addEdge(8, 9);
return g;
}
开发者ID:openfurther,项目名称:further-open-core,代码行数:30,代码来源:GraphTestUtil.java
示例15: checkChildrenSets
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
private void checkChildrenSets(Set<String> oidsToCheck) {
SimpleDirectedGraph<String,DefaultEdge> tc = (SimpleDirectedGraph) orgGraph.clone();
TransitiveClosure.INSTANCE.closeSimpleDirectedGraph(tc);
for (String subroot : oidsToCheck) {
LOGGER.info("Checking descendants of {}", subroot);
Set<String> expectedChildren = new HashSet<>();
for (DefaultEdge edge : tc.incomingEdgesOf(subroot)) {
expectedChildren.add(tc.getEdgeSource(edge));
}
expectedChildren.add(subroot);
LOGGER.trace("Expected children: {}", expectedChildren);
Set<String> actualChildren = getActualChildrenOf(subroot);
LOGGER.trace("Actual children: {}", actualChildren);
Set<String> expectedMinusActual = new HashSet<>(expectedChildren);
expectedMinusActual.removeAll(actualChildren);
if (!expectedMinusActual.isEmpty()) {
System.out.println("Expected-Actual = " + expectedMinusActual);
}
Set<String> actualMinusExpected = new HashSet<>(actualChildren);
actualMinusExpected.removeAll(expectedChildren);
if (!actualMinusExpected.isEmpty()) {
System.out.println("Actual-Expected = " + actualMinusExpected);
}
assertEquals("Incorrect children for " + subroot, expectedChildren, actualChildren);
}
}
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:28,代码来源:AbstractOrgClosureTest.java
示例16: getConfigurations
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
public Collection<ConfClass> getConfigurations(ConfClass confObject, Properties props) {
Class<? extends Object> confClass = confObject.getClass();
HashMap<String, Field> parameters = new HashMap<>();
DirectedGraph<Field, DefaultEdge> dependencyGraph = new SimpleDirectedGraph<>(DefaultEdge.class);
HashMap<Field, DependsOn> rawDependencies = new HashMap<>();
for (Field f : confClass.getFields()) {
dependencyGraph.addVertex(f);
parameters.put(f.getName(), f);
if (f.isAnnotationPresent(DependsOn.class)) {
DependsOn depOn = f.getAnnotation(DependsOn.class);
rawDependencies.put(f, depOn);
}
}
for (Entry<Field, DependsOn> entry : rawDependencies.entrySet()) {
String otherParam = entry.getValue().parameter();
if (!parameters.containsKey(otherParam)) {
throw new RuntimeException("Parameter dependency '" + otherParam + "' referenced from '"
+ entry.getKey() + "' not found!");
}
Field otherField = parameters.get(otherParam);
// read this edge as "otherField" before "entry.getKey()"
dependencyGraph.addEdge(otherField, entry.getKey());
}
List<Field> consistentOrdering = getParameterOrdering(dependencyGraph);
Collection<ConfClass> configurations = enumerateConfigurations(confObject, consistentOrdering, parameters,
props);
return configurations;
}
开发者ID:isse-augsburg,项目名称:minibrass,代码行数:35,代码来源:ConfigurationProvider.java
示例17: preClose
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
@Override
public void preClose() {
DirectedGraph<String, String> graph = new SimpleDirectedGraph<>(String.class);
addVerticesToGraph(graph);
addEdgesToGraph(graph);
depthFirstSearchAndWriteOutResults(graph);
}
开发者ID:phenopolis,项目名称:pheno4j,代码行数:9,代码来源:TermToDescendantTermsSubscriber.java
示例18: JGraphTGraphAdapter
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
* Creates a new Graph.
*
* @param edgeFact
* The edgefactory to use for this graph.
*/
public JGraphTGraphAdapter(final JGraphTEdgeFactory<V> edgeFact) {
internalGraph = new SimpleDirectedGraph<V, DefaultEdge>(
DefaultEdge.class);
this.edgeFact = edgeFact;
sources = new TreeSet<>();
sinks = new TreeSet<>();
vertexIdentifiers = new ArrayList<>();
}
开发者ID:ProgrammingLife2015,项目名称:LifeTiles,代码行数:15,代码来源:JGraphTGraphAdapter.java
示例19: addEdge
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
* This method is synchronized and adds an edge and its associated vertices to simple directed graph stored in static memory of this process.
*
* @param graph synchronized parameter contains a reference to simple digraph {@code org.jgrapht.graph.SimpleDirectedGraph}.
* @param relation contains parent-child relationship targeted for addition.
* @return {@code org.jgrapht.graph.SimpleDirectedGraph} containing the vertices of {@code String}, and edges, as {@link Relationship}s that correspond to relational data.
*/
private static void addEdge( SimpleDirectedGraph<String, Relationship> graph, Relationship relation )
{
LOG.debug( "addEdge" );
synchronized ( graph )
{
graph.addVertex( relation.getChild().toUpperCase() );
graph.addVertex( relation.getParent().toUpperCase() );
graph.addEdge( relation.getChild().toUpperCase(), relation.getParent().toUpperCase(), relation );
}
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:18,代码来源:HierUtil.java
示例20: removeEdge
import org.jgrapht.graph.SimpleDirectedGraph; //导入依赖的package包/类
/**
* This method is synchronized and removes an edge from a simple directed graph stored in static memory of this process.
*
* @param graph synchronized parameter contains a reference to simple digraph {@code org.jgrapht.graph.SimpleDirectedGraph}.
* @param relation contains parent-child relationship targeted for removal.
* @return {@code org.jgrapht.graph.SimpleDirectedGraph} containing the vertices of {@code String}, and edges, as {@link Relationship}s that correspond to relational data.
*/
private static void removeEdge( SimpleDirectedGraph<String, Relationship> graph, Relationship relation )
{
LOG.debug( "removeEdge" );
synchronized ( graph )
{
graph.removeEdge( relation );
}
}
开发者ID:apache,项目名称:directory-fortress-core,代码行数:16,代码来源:HierUtil.java
注:本文中的org.jgrapht.graph.SimpleDirectedGraph类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论