Examples of EdgeList


Examples of com.intel.hadoop.graphbuilder.graph.glgraph.EdgeList

    // assertEquals("Num out edges", testNumEdges, numOutEdgesExpect);

    // check inedges(vid), outedges(vid)
    // iterate out edges of 0: 3, 6, 1
    HashSet<Integer> testEdges = new HashSet<Integer>();
    EdgeList list = myGraph.outEdges(myGraph.lvid(0));
    Iterator<EdgeType> iter = list.iterator();
    testEdges.add(myGraph.lvid(3));
    testEdges.add(myGraph.lvid(6));
    testEdges.add(myGraph.lvid(1));
    while (iter.hasNext()) {
      EdgeType e = iter.next();
      assertEquals(e.source(), myGraph.lvid(0));
      assertTrue(testEdges.contains(e.target()));
    }
    // iterate out edges of 1: null
    list = myGraph.outEdges(myGraph.lvid(1));
    assertTrue(list.isEmpty());

    // iterate in edges of 3: 0, 2
    list = myGraph.inEdges(myGraph.lvid(3));
    testEdges.clear();
    testEdges.add(myGraph.lvid(0));
    testEdges.add(myGraph.lvid(2));
    iter = list.iterator();
    while (iter.hasNext()) {
      EdgeType e = iter.next();
      assertEquals(e.target(), myGraph.lvid(3));
      assertTrue(testEdges.contains(e.source()));
    }
    // iterate in edges of 2: null
    list = myGraph.inEdges(myGraph.lvid(2));
    assertTrue(list.isEmpty());
  }
View Full Code Here

Examples of org.eclipse.draw2d.graph.EdgeList

   */
  private CompoundDirectedGraph mapDiagramToGraph() {
    Map<AnchorContainer, Node> shapeToNode = new HashMap<AnchorContainer, Node>();
    Diagram d = getDiagram();
    CompoundDirectedGraph dg = new CompoundDirectedGraph();
    EdgeList edgeList = new EdgeList();
    NodeList nodeList = new NodeList();
    EList<Shape> children = d.getChildren();
    for (Shape shape : children) {
      Node node = new Node();
      GraphicsAlgorithm ga = shape.getGraphicsAlgorithm();
      node.x = ga.getX();
      node.y = ga.getY();
      node.width = ga.getWidth();
      node.height = ga.getHeight();
      node.data = shape;
      shapeToNode.put(shape, node);
      nodeList.add(node);
    }
    EList<Connection> connections = d.getConnections();
    for (Connection connection : connections) {
     
      //Be wary about broken connections
      AnchorContainer source = null;
      if (connection.getStart() != null) {
        source = connection.getStart().getParent();
      }
     
      AnchorContainer target = null;
      if (connection.getEnd() != null) {
        target = connection.getEnd().getParent();
      }
     
      if (target == null || source == null) {
        break;
      }
     
      Node srcNode = shapeToNode.get(source);
      if (srcNode == null) {
        srcNode = shapeToNode.get(source.eContainer());
      }
     
      Node tgtNode = shapeToNode.get(target);
      if (tgtNode == null) {
        tgtNode = shapeToNode.get(target.eContainer());
      }
      Edge edge = new Edge(srcNode, tgtNode);
      edge.data = connection;
      edgeList.add(edge);
    }
    dg.nodes = nodeList;
    dg.edges = edgeList;
    return dg;
  }
View Full Code Here

Examples of org.eclipse.draw2d.graph.EdgeList

  {
    DiagramModel diagramModel = diagramEditor.getDiagramModel();
    Map<DiagramNodeModel, Node> shapeToNode = new HashMap<DiagramNodeModel, Node>();
    DirectedGraph dg = new DirectedGraph();
    dg.setDirection(getGraphDirection());
    EdgeList edgeList = new EdgeList();
    NodeList nodeList = new NodeList();
    List<DiagramNodeModel> children = diagramModel.getNodes();
    for (DiagramNodeModel child : children)
    {
      Node node = new Node();
      Rectangle bounds = child.getShapePresentation().getFigure().getBounds();//child.getNodeBounds();
      node.x = bounds.x;
      node.y = bounds.y;
      node.width = bounds.width;
      node.height = bounds.height;
      node.data = child;
      shapeToNode.put(child, node);
      nodeList.add(node);
    }
    List<DiagramConnectionModel> connections = diagramModel.getConnections();
    for (DiagramConnectionModel connection : connections)
    {
      DiagramNodeModel sourceNode = connection.getSourceNode();
      DiagramNodeModel targetNode = connection.getTargetNode();
      if (sourceNode != targetNode)
      {
        Edge edge = new Edge(connection, shapeToNode.get(sourceNode), shapeToNode.get(targetNode));
        edge.weight = 2;
        edge.data = connection;
        edgeList.add(edge);
      }
    }
    dg.nodes = nodeList;
    dg.edges = edgeList;
    return dg;
View Full Code Here

Examples of org.eclipse.draw2d.graph.EdgeList

  @SuppressWarnings("unchecked")
  private void mapGraphEdgeCoordinatesToDiagram(DirectedGraph graph,
      final SapphireDiagramEditor diagramEditor, final boolean autoLayout)
  {
    // add bend points generated by the graph layout
    EdgeList myEdges = new EdgeList();
    myEdges.addAll(graph.edges);
    DiagramConfigurationManager configManager = diagramEditor.getConfigurationManager();
   
    for (Object object : myEdges)
    {
      Edge edge = (Edge)object;
View Full Code Here

Examples of org.eclipse.draw2d.graph.EdgeList

  private CompoundDirectedGraph mapDiagramToGraph() {
    Map<AnchorContainer, Node> shapeToNode = new HashMap<AnchorContainer, Node>();
    Diagram d = getDiagram();
    CompoundDirectedGraph dg = new CompoundDirectedGraph();
    EdgeList edgeList = new EdgeList();
    NodeList nodeList = new NodeList();
    EList<Shape> children = d.getChildren();
    for (Shape shape : children) {
      Node node = new Node();
      GraphicsAlgorithm ga = shape.getGraphicsAlgorithm();
      node.x = ga.getX();
      node.y = ga.getY();
      node.width = ga.getWidth();
      node.height = ga.getHeight();
      node.data = shape;
      shapeToNode.put(shape, node);
      nodeList.add(node);
    }
    EList<Connection> connections = d.getConnections();
    for (Connection connection : connections) {
      AnchorContainer source = connection.getStart().getParent();
      AnchorContainer target = connection.getEnd().getParent();
      Edge edge = new Edge(shapeToNode.get(source), shapeToNode.get(target));
      edge.data = connection;
      edgeList.add(edge);
    }
    dg.nodes = nodeList;
    dg.edges = edgeList;
    return dg;
  }
View Full Code Here

Examples of org.eclipse.draw2d.graph.EdgeList

    // Remove all unreferenced single beans and connect all unreferenced
    // subgraphs with a temporary root bean
    Bean root = new Bean();
    graph.nodes.add(root);

    EdgeList rootEdges = new EdgeList();
    List<Bean> orphanBeans = new ArrayList<Bean>();
    beans = getBeans().iterator();
    while (beans.hasNext()) {
      Bean bean = (Bean) beans.next();
      if (bean.incoming.isEmpty() && bean.outgoing.isEmpty()) {
        orphanBeans.add(bean);
        graph.nodes.remove(bean);
      }
      else {
        Reference reference = new Reference(BeanType.STANDARD, root, bean, false);
        reference.weight = 0;
        rootEdges.add(reference);
        graph.edges.add(reference);
      }
    }

    // Calculate position of all beans in graph
    try {
      new DirectedGraphLayout().visit(graph);

      // Re-invert edges inverted while breaking cycles; this only seems to be required on earlier GEF versions
      if (!SpringCoreUtils.isEclipseSameOrNewer(3, 6)) {
        for (int i = 0; i < graph.edges.size(); i++) {
          Edge e = graph.edges.getEdge(i);
          if (e.isFeedback()) {
            e.invert();
          }
        }
      }

      // Remove temporary root and root edges
      for (int i = 0; i < rootEdges.size(); i++) {
        Edge e = rootEdges.getEdge(i);
        e.source.outgoing.remove(e);
        e.target.incoming.remove(e);
        graph.edges.remove(e);
      }
      graph.nodes.remove(root);
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

    // FIXME instead of doing the following check set a flag when the edge is added
    // check that x has to have at least one r neighbor y
    // which is blockable and has successor x
    // (so y is an inv(r) predecessor of x)
    boolean apply = false;
    EdgeList edges = x.getRPredecessorEdges(r.getInverse());
    for (int e = 0; e < edges.size(); e++) {
      Edge edge = edges.edgeAt(e);
      Individual pred = edge.getFrom();
      if (pred.isBlockable()) {
        apply = true;
        break;
      }
    }
    if (!apply)
      return;

    if (x.getMaxCard(r) < n)
      return;

    if (x.hasDistinctRNeighborsForMin(r, n, ATermUtils.TOP, true))
      return;

    // if( n == 1 ) {
    // throw new InternalReasonerException(
    // "Functional rule should have been applied " +
    // x + " " + x.isNominal() + " " + edges);
    // }

    int guessMin = x.getMinCard(r, c);
    if (guessMin == 0)
      guessMin = 1;

    // TODO not clear what the correct ds is so be pessimistic and include everything
    DependencySet ds = x.getDepends(mc);
    edges = x.getRNeighborEdges(r);
    for (int e = 0; e < edges.size(); e++) {
      Edge edge = edges.edgeAt(e);
      ds = ds.union(edge.getDepends(), strategy.getABox().doExplanation());
    }

    GuessBranch newBranch = new GuessBranch(strategy.getABox(), strategy, x, r, guessMin, n, c, ds);
    strategy.addBranch(newBranch);
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

        Node y = null;
        Edge edge = null;

        // edges contains all the edges going into of coming out from the node
        // And labeled with the role R
        EdgeList edges = x.getRNeighborEdges( role );
        // We examine all those edges one by one and check if the neighbor has
        // type C, in which case we set neighborFound to true
        for( Iterator<Edge> i = edges.iterator(); i.hasNext(); ) {
            edge = i.next();

            y = edge.getNeighbor( x );           
           
            if( PelletOptions.USE_COMPLETION_QUEUE && y.isPruned() ){
                y = null;
                continue;
            }              
           
            if( y.hasType( c ) ) {
              neighborFound = neighborSafe || y.isLiteral() || !strategy.getBlocking().isBlocked( (Individual) y );
                if( neighborFound ) {
                    break;
                }
            }
        }

        // If we have found a R-neighbor with type C, continue, do nothing
        if( neighborFound )
            return;

        // If not, we have to create it
        // If the role is a datatype property...
        if( role.isDatatypeRole() ) {
            Literal literal = (Literal) y;
      if( ATermUtils.isNominal( c ) && !PelletOptions.USE_PSEUDO_NOMINALS ) {
        strategy.getABox().copyOnWrite();

        final ATermAppl input = (ATermAppl) c.getArgument( 0 );
        ATermAppl canonical;
        if( input.getArgument( ATermUtils.LIT_URI_INDEX ).equals( ATermUtils.NO_DATATYPE ) ) {
          canonical = input;
        }
        else {
          try {
            canonical = strategy.getABox().getDatatypeReasoner().getCanonicalRepresentation( input );
          } catch( InvalidLiteralException e ) {
            final String msg = "Invalid literal encountered in nominal when attempting to apply some values rule: "
                + e.getMessage();
            throw new InternalReasonerException( msg, e );
          } catch( UnrecognizedDatatypeException e ) {
            final String msg = "Unrecognized datatype for literal encountered in nominal when attempting to apply some values rule: "
                + e.getMessage();
            throw new InternalReasonerException( msg, e );
          }
        }
        literal = strategy.getABox().addLiteral( canonical );
      }
            else {
                if( !role.isFunctional() || literal == null ) {
                    literal = strategy.getABox().addLiteral( ds );
                }
                else {
                  ds = ds.union( role.getExplainFunctional(), strategy.getABox().doExplanation()  );
                  ds = ds.union( edge.getDepends(), strategy.getABox().doExplanation()  );
                }
                strategy.addType( literal, c, ds );
            }
           
            if( log.isLoggable( Level.FINE ) )
                log.fine( "SOME: " + x + " -> " + s + " -> " + literal + " : " + ATermUtils.toString( c ) + " - " + ds );
           
            strategy. addEdge( x, role, literal, ds );
        }
        // If it is an object property
        else {
            if( ATermUtils.isNominal( c ) && !PelletOptions.USE_PSEUDO_NOMINALS ) {
                strategy.getABox().copyOnWrite();

                ATermAppl value = (ATermAppl) c.getArgument( 0 );
                y = strategy.getABox().getIndividual( value );

                if( log.isLoggable( Level.FINE ) )
                    log.fine( "VAL : " + x + " -> " + ATermUtils.toString( s ) + " -> " + y + " - " + ds );

                if( y == null ) {
                    if( ATermUtils.isAnonNominal( value ) ) {
                        y = strategy.getABox().addIndividual( value, ds );
                    }
                    else if( ATermUtils.isLiteral( value ) )
                        throw new InternalReasonerException( "Object Property " + role
                            + " is used with a hasValue restriction "
                            + "where the value is a literal: " + ATermUtils.toString( value ) );
                    else
                        throw new InternalReasonerException( "Nominal " + c
                            + " is not found in the KB!" );
                }

                if( y.isMerged() ) {
                    ds = ds.union( y.getMergeDependency( true ), strategy.getABox().doExplanation() );

                    y = y.getSame();
                }

                strategy.addEdge( x, role, y, ds );
            }
            else {
                boolean useExistingNode = false;
                boolean useExistingRole = false;
                DependencySet maxCardDS = role.isFunctional()
          ? role.getExplainFunctional()
          : x.hasMax1( role );
                if( maxCardDS != null ) {
                    ds = ds.union( maxCardDS, strategy.getABox().doExplanation() );

                    // if there is an r-neighbor and we can have at most one r then
                    // we should reuse that node and edge. there is no way that neighbor
                    // is not safe (a node is unsafe only if it is blockable and has
                    // a nominal successor which is not possible if there is a cardinality
                    // restriction on the property)
                    if( edge != null ) {
                        useExistingRole = useExistingNode = true;                      
                    }
                    else {
                        // this is the tricky part. we need some merges to happen
                        // under following conditions:
                        // 1) if r is functional and there is a p-neighbor where
                        // p is superproperty of r then we need to reuse that
                        // p neighbor for the some values restriction (no
                        // need to check subproperties because functionality of r
                        // precents having two or more successors for subproperties)
                        // 2) if r is not functional, i.e. max(r, 1) is in the types,
                        // then having a p neighbor (where p is subproperty of r)
                        // means we need to reuse that p-neighbor
                        // In either case if there are more than one such value we also
                        // need to merge them together
                        Set<Role> fs = role.isFunctional() ? role.getFunctionalSupers() : role
                            .getSubRoles();
                       
                        for( Iterator<Role> it = fs.iterator(); it.hasNext(); ) {
                            Role f = it.next();
                            edges = x.getRNeighborEdges( f );
                            if( !edges.isEmpty() ) {
                                if( useExistingNode ) {
                                  DependencySet fds = DependencySet.INDEPENDENT;
                                  if (PelletOptions.USE_TRACING) {
                                    if (role.isFunctional()) {
                                      fds = role.getExplainSuper(f.getName());
                                    } else {
                                      fds = role.getExplainSub(f.getName());
                                    }
                                  }
                                    Edge otherEdge = edges.edgeAt( 0 );
                                    Node otherNode = otherEdge.getNeighbor( x );
                                    DependencySet d = ds.union( edge.getDepends(), strategy.getABox().doExplanation() ).union(
                                        otherEdge.getDepends(), strategy.getABox().doExplanation() ).union(fds, strategy.getABox().doExplanation());
                                    strategy.mergeTo( y, otherNode, d );
                                }
                                else {
                                    useExistingNode = true;
                                    edge = edges.edgeAt( 0 );
                                    y = edge.getNeighbor( x );
                                }
                            }
                        }
                        if( y != null )
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

    if ( s.isTop() && s.isObjectRole() ) {
          applyAllValuesTop( av, c, ds );
          return;
        }
   
    EdgeList edges = x.getRNeighborEdges( s );
    for( int e = 0; e < edges.size(); e++ ) {
      Edge edgeToY = edges.edgeAt( e );
      Node y = edgeToY.getNeighbor( x );
      DependencySet finalDS = ds.union( edgeToY.getDepends(), strategy.getABox().doExplanation() );
      if( strategy.getABox().doExplanation() ) {
        Role edgeRole = edgeToY.getRole();
        DependencySet subDS = s.getExplainSubOrInv( edgeRole );
        finalDS = finalDS.union( subDS.getExplain(), true );
      }
     
      applyAllValues( x, s, y, c, finalDS );

      if( x.isMerged() )
        return;
    }

    if( !s.isSimple() ) {
      for( Role r : s.getTransitiveSubRoles() ) {
        ATermAppl allRC = ATermUtils.makeAllValues( r.getName(), c );

        edges = x.getRNeighborEdges( r );
        for( int e = 0; e < edges.size(); e++ ) {
          Edge edgeToY = edges.edgeAt( e );
          Node y = edgeToY.getNeighbor( x );
          DependencySet finalDS = ds.union( edgeToY.getDepends(), strategy.getABox().doExplanation() );
          if( strategy.getABox().doExplanation() ) {
            finalDS = finalDS.union( r.getExplainTransitive().getExplain(), true );
            finalDS = finalDS.union( s.getExplainSubOrInv( edgeToY.getRole() ), true );
View Full Code Here

Examples of org.mindswap.pellet.EdgeList

            return;
       
        if(!PelletOptions.MAINTAIN_COMPLETION_QUEUE && x.getDepends(maxCard) == null)
          return;

        EdgeList edges = x.getRNeighborEdges( r );
        for( Iterator<Edge> i = edges.iterator(); i.hasNext(); ) {
            Edge edge = i.next();
            Node neighbor = edge.getNeighbor( x );

            if( !neighbor.hasType( c ) && !neighbor.hasType( ATermUtils.negate( c ) ) ) {
                ChooseBranch newBranch = new ChooseBranch( strategy.getABox(), strategy, neighbor, c, x
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.