Examples of SimpleGraph


Examples of org.apache.clerezza.rdf.core.impl.SimpleGraph

        super(wrappedMGraph);
    }

    @Override
    public Graph getGraph() {
        return new SimpleGraph(this);
    }
View Full Code Here

Examples of org.apache.clerezza.rdf.core.impl.SimpleGraph

        } catch (NoSuchEntityException e) {
            Graph result;
            if (Graph.class.isAssignableFrom(triples.getClass())) {
                result = (Graph) triples;
            } else {
                result = new SimpleGraph(triples);
            }
            tripleMap.put(name, result);

            return result;
        }
View Full Code Here

Examples of org.jamesii.core.util.graph.SimpleGraph

  @Override
  public ISimpleGraph analyzeModel(IModel model) {

    if (!(model instanceof ICAGrid)) {
      modelGraph = new SimpleGraph(1);
      return modelGraph;
    }

    ICAGrid caModel = (ICAGrid) model;

    int vertexCount = countNodes(caModel);

    modelGraph = new SimpleGraph(vertexCount);

    createEdges(caModel);

    // Setting calculation costs equally
    for (int i = 0; i < vertexCount; i++) {
View Full Code Here

Examples of org.jamesii.core.util.graph.SimpleGraph

  /**
   * Tests the cycle detection.
   */
  public void testCycleDetection() {
    SimpleGraph simpleGraph = new SimpleGraph(5);
    simpleGraph.addEdge(new AnnotatedEdge<Integer, Double, Object>(0, 1));
    simpleGraph.addEdge(new AnnotatedEdge<Integer, Double, Object>(1, 2));
    simpleGraph.addEdge(new AnnotatedEdge<Integer, Double, Object>(2, 3));
    simpleGraph.addEdge(new AnnotatedEdge<Integer, Double, Object>(3, 4));
    List<Integer> cycle = CycleDetection.detectCycle(simpleGraph);
    assertTrue("There is no cycle in the given graph.", cycle.isEmpty());
    simpleGraph.addEdge(new AnnotatedEdge<Integer, Double, Object>(4, 2));
    cycle = CycleDetection.detectCycle(simpleGraph);
    assertTrue(
        "There is a cycle (2,3,4) in the given graph.",
        cycle.size() == 3 && cycle.contains(2) && cycle.contains(3)
            && cycle.contains(4));
View Full Code Here

Examples of org.jamesii.core.util.graph.SimpleGraph

  /**
   * Simple test of Dijkstra algorithm.
   */
  public void testSimpleExample() {
    SimpleGraph graph = createTestGraph();

    Map<Integer, Double> pathLengths = dijkstra.compute(graph, 0);
    addInformation("Calculated result:" + Strings.dispMap(pathLengths));

    assertEquals("There should be a path length for each vertex.",
        graph.getVertexCount(), pathLengths.size());
    for (Integer vertex : graph.getVertices()) {
      assertNotNull(pathLengths.get(vertex));
      assertFalse(Double.isInfinite(vertex));
    }

    // Check true solution:
View Full Code Here

Examples of org.jamesii.core.util.graph.SimpleGraph

  /**
   * Test unconnected graph. All distances (except to the start node) should be
   * infinite.
   */
  public void testUnconnectedGraph() {
    SimpleGraph graph = new SimpleGraph(NUM_OF_VERTICES_EMPTY_GRAPH);
    Map<Integer, Double> pathLengths = dijkstra.compute(graph, 0);
    for (int i = 1; i < NUM_OF_VERTICES_EMPTY_GRAPH; i++) {
      assertTrue(Double.isInfinite(pathLengths.get(i)));
    }
  }
View Full Code Here

Examples of org.jamesii.core.util.graph.SimpleGraph

   * href="http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm">Wikipedia</a>.
   *
   * @return the graph
   */
  private SimpleGraph createTestGraph() {
    SimpleGraph testGraph = new SimpleGraph(6);

    testGraph.addEdge(new AnnotatedEdge<>(0, 1, 7.));
    testGraph.addEdge(new AnnotatedEdge<>(0, 2, 9.));
    testGraph.addEdge(new AnnotatedEdge<>(0, 5, 14.));

    testGraph.addEdge(new AnnotatedEdge<>(1, 2, 10.));
    testGraph.addEdge(new AnnotatedEdge<>(1, 3, 15.));

    testGraph.addEdge(new AnnotatedEdge<>(2, 3, 11.));
    testGraph.addEdge(new AnnotatedEdge<>(2, 5, 2.));

    testGraph.addEdge(new AnnotatedEdge<>(3, 4, 6.));

    testGraph.addEdge(new AnnotatedEdge<>(4, 5, 9.));
    return testGraph;
  }
View Full Code Here

Examples of org.jamesii.core.util.graph.SimpleGraph

   *          the number of nodes
   *
   * @return the random simple graph
   */
  public ISimpleGraph getRandomSimpleGraph(int numberOfNodes) {
    return getRandomSimpleGraph(new SimpleGraph(numberOfNodes));
  }
View Full Code Here

Examples of org.wymiwyg.rdf.graphs.impl.SimpleGraph

          try {
            Subject.doAsPrivileged(null, new PrivilegedExceptionAction() {
              public Object run() throws Exception {
                Source source = new SourceImpl("http://example.org/graph-source");
                try {
                  store.assertGraph(source, new FCAGraphImpl(new SimpleGraph()));
                } catch (AccessControlException ex) {
                  exceptionCatched[0] = true;
                }
                return null;
              }
View Full Code Here

Examples of org.wymiwyg.rdf.graphs.impl.SimpleGraph

        }
      } else {
        relevantTriples.add(triple);
      }
    }
    SimpleGraph result = new SimpleGraph();
    for (Triple triple : relevantTriples) {
      result.add(new TripleImpl(replaceIfPossible(triple.getSubject(),
          map), triple.getPredicate(), replaceIfPossible(triple
          .getObject(), map)));
    }
    result.markFinalized();
    return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.