Package weka.gui.graphvisualizer

Examples of weka.gui.graphvisualizer.GraphNode


  public void layoutCompleted(LayoutCompleteEvent le) {
    LayoutEngine layoutEngine  = m_layoutEngine; // (LayoutEngine) le.getSource();
    FastVector nPosX = new FastVector(m_BayesNet.getNrOfNodes());
    FastVector nPosY = new FastVector(m_BayesNet.getNrOfNodes());
    for (int iNode = 0; iNode < layoutEngine.getNodes().size(); iNode++) {
      GraphNode gNode = (GraphNode) layoutEngine.getNodes().elementAt(iNode);
      if (gNode.nodeType == GraphNode.NORMAL) {
        nPosX.addElement(gNode.x);
        nPosY.addElement(gNode.y);
      }
    }
View Full Code Here


 
  protected void nodeID(StreamTokenizer tk) throws Exception{
   
    if(tk.ttype=='"' || tk.ttype==tk.TT_WORD || (tk.ttype>='a' && tk.ttype<='z')
    || (tk.ttype>='A' && tk.ttype<='Z')) {
      if(m_nodes!=null && !(m_nodes.contains( new GraphNode(tk.sval, null))) ) {
        m_nodes.addElement( new GraphNode(tk.sval, tk.sval) );
        //System.out.println("Added node >"+tk.sval+"<");
      }
    }
    else
    { throw new Exception(); }
View Full Code Here

 
  protected void nodeStmt(StreamTokenizer tk, final int nindex)
  throws Exception {
    tk.nextToken();
   
    GraphNode temp = (GraphNode) m_nodes.elementAt(nindex);
   
    if(tk.ttype==']' || tk.ttype==tk.TT_EOF)
      return;
    else if(tk.ttype==tk.TT_WORD) {
     
View Full Code Here

          if(tk.ttype=='}')
            break;
          else {
            nodeID(tk);
            e = new GraphEdge(nindex,
            m_nodes.indexOf( new GraphNode(tk.sval, null) ),
            DIRECTED);
            if( m_edges!=null && !(m_edges.contains(e)) ) {
              m_edges.addElement( e );
              //System.out.println("Added edge from "+
              //                  ((GraphNode)(m_nodes.elementAt(nindex))).ID+
              //                  " to "+
              //          ((GraphNode)(m_nodes.elementAt(e.dest))).ID);
            }
          }
        }
      }
      else {
        nodeID(tk);
        e = new GraphEdge(nindex,
        m_nodes.indexOf( new GraphNode(tk.sval, null) ),
        DIRECTED);
        if( m_edges!=null && !(m_edges.contains(e)) ) {
          m_edges.addElement( e );
          //System.out.println("Added edge from "+
          //                 ((GraphNode)(m_nodes.elementAt(nindex))).ID+" to "+
View Full Code Here

   
    //****Updating edges[][] array of nodes from
    //****the interconnection matrix, which will be used
    //****by the Visualizer class to draw edges
    for(int i=0; i<graphMatrix.length; i++) {
      GraphNode n = (GraphNode)m_nodes.elementAt(i);
      int sum=0;
      for(int j=0; j<graphMatrix[i].length; j++)
        if(graphMatrix[i][j]!=0)
          sum++;
     
View Full Code Here

                   [graphMatrix.length+(nodesLevel[i]-nodesLevel[n]-1)];
            int level = nodesLevel[n]+1;
            copyMatrix(graphMatrix, tempMatrix);
           
            String s1 = new String("S"+tempCnt++);
            m_nodes.addElement(new GraphNode(s1, s1, SINGULAR_DUMMY)); //true));
            int temp3 [] = new int[nodeLevels[level].length+1];
            //for(int j=0; j<nodeLevels[level].length; j++)
            //    temp3[j] = nodeLevels[level][j];
            System.arraycopy(nodeLevels[level], 0, temp3,
                             0, nodeLevels[level].length);
            temp3[temp3.length-1] = m_nodes.size()-1;
            nodeLevels[level] = temp3; level++;
            //nodeLevels[level++].addElement(new Integer(m_nodes.size()-1));
            //System.out.println("len:"+len+","+nodesLevel[i]+","+
            //                   nodesLevel[n]);
           
            int k;
            for(k=len; k<len+nodesLevel[i]-nodesLevel[n]-1-1; k++) {
              String s2 =  new String("S"+tempCnt);
              m_nodes.addElement( new GraphNode(s2, s2, SINGULAR_DUMMY) ); //true) );
              temp3 = new int[nodeLevels[level].length+1];
              //for(int j=0; j<nodeLevels[level].length; j++)
              //  temp3[j] = nodeLevels[level][j];
              System.arraycopy(nodeLevels[level], 0, temp3,
                               0, nodeLevels[level].length);
View Full Code Here

            int level = nodesLevel[tempnode]+1;
            copyMatrix(graphMatrix, tempMatrix);
           
            String s1 = new String("S"+tempCnt++);
            //System.out.println("Adding dummy "+s1);
            m_nodes.addElement(new GraphNode(s1, s1, SINGULAR_DUMMY));
           
            int temp3 [] = new int[nodeLevels[level].length+1];
            System.arraycopy(nodeLevels[level], 0, temp3,
                             0, nodeLevels[level].length);
            temp3[temp3.length-1] = m_nodes.size()-1;
            nodeLevels[level] = temp3;
            temp3 = new int[m_nodes.size()+1];
            System.arraycopy(nodesLevel, 0, temp3, 0, nodesLevel.length);
            temp3[m_nodes.size()-1] = level;
            nodesLevel = temp3;
            level++;
            //nodeLevels[level++].addElement(new Integer(m_nodes.size()-1));
            //System.out.println("len:"+len+"("+
            //                   ((GraphNode)m_nodes.elementAt(len)).ID+"),"+
            //                   nodesLevel[i]+","+nodesLevel[tempnode]);
           
            int m;
            for(m=len; m<len+nodesLevel[i]-nodesLevel[tempnode]-1-1; m++) {
              String s2 =  new String("S"+tempCnt++);
              //System.out.println("Adding dummy "+s2);
              m_nodes.addElement( new GraphNode(s2, s2, SINGULAR_DUMMY) );
              temp3 = new int[nodeLevels[level].length+1];
              //for(int j=0; j<nodeLevels[level].length; j++)
              //  temp3[j] = nodeLevels[level][j];
              System.arraycopy(nodeLevels[level], 0, temp3,
                               0, nodeLevels[level].length);
View Full Code Here

      int edgeOcrnce[] = new int[m_nodes.size()];
     
      for(int j=0,uidx=0,lidx=0; j<(levels[i].length+levels[i+1].length); j++) {
        if((j%2==0 && uidx<levels[i].length) || lidx>=levels[i+1].length) {
          int k1=0, k2=0, k3=0;
          GraphNode n = (GraphNode) m_nodes.elementAt(levels[i][uidx]);
          //Deactivating and counting crossings for all edges ending in it
          //coming from bottom left
          if(lastOcrnce[levels[i][uidx]]!=null) {
            MyListNode temp = new MyListNode(-1); temp.next = upper.first;
            try {
              do {
                temp = temp.next;
                if(levels[i][uidx]==temp.n) {
                  k1 = k1+1;
                  k3 = k3+k2;
                  //System.out.println("Removing from upper: "+temp.n);
                  upper.remove(temp);
                }
                else
                  k2 = k2+1;
              } while(temp!=lastOcrnce[levels[i][uidx]]);
            }
            catch(NullPointerException ex) {
              System.out.println(Messages.getInstance().getString("HierarchicalBCEngine_Crossings_Exception_Text_First") + levels[i][uidx]+
                  Messages.getInstance().getString("HierarchicalBCEngine_Crossings_Exception_Text_Second") + ((GraphNode)m_nodes.elementAt(levels[i][uidx])).ID+
                  Messages.getInstance().getString("HierarchicalBCEngine_Crossings_Exception_Text_Third") + temp+
                  Messages.getInstance().getString("HierarchicalBCEngine_Crossings_Exception_Text_Fourth") + upper.first);
            ex.printStackTrace();
            System.exit(-1);}
           
            lastOcrnce[levels[i][uidx]]=null;
            sum = sum + k1*lower.size() + k3;
          }
          //Activating all the edges going out towards the bottom
          //and bottom right
          for(int k=0; k<n.edges.length; k++) {
            if(n.edges[k][1]>0)
              try {
                if( indexOfElementInLevel(n.edges[k][0], levels[i+1]) >= uidx) {
                  edgeOcrnce[n.edges[k][0]]=1;
                }
              }
              catch(Exception ex) {
                ex.printStackTrace();
              }
          }
          for(int k=0; k<levels[i+1].length; k++) {
            if(edgeOcrnce[levels[i+1][k]]==1) {
              MyListNode temp = new MyListNode(levels[i+1][k]); //new MyListNode(n.edges[k][0]);
              lower.add(temp);
              lastOcrnce[levels[i+1][k]] = temp;
              edgeOcrnce[levels[i+1][k]] = 0;
              //System.out.println("Adding to lower: "+levels[i+1][k]+
              //" which is: "+((GraphNode)m_nodes.elementAt(levels[i+1][k])).ID+
              //" first's n is: "+lower.first.n);
            }
           
          }
          uidx++;
        }
        else {
          int k1=0, k2=0, k3=0;
          GraphNode n = (GraphNode) m_nodes.elementAt(levels[i+1][lidx]);
          //Deactivating and counting crossings for all edges ending in it
          //coming from up and upper left
          if(lastOcrnce[levels[i+1][lidx]]!=null) {
           
            MyListNode temp = new MyListNode(-1); temp.next = lower.first;
View Full Code Here

  /**
   * See Sugiyama et al. 1981 (full reference give at top)
   */
  protected float [] calcRowBC(final int lindex, final int levels[][]){
    float rowBC[] = new float[levels[lindex].length];
    GraphNode n;
   
    for(int i=0; i<levels[lindex].length; i++) {
      int sum=0;
      n = (GraphNode)m_nodes.elementAt(levels[lindex][i]);
     
View Full Code Here

  /**
   * See Sugiyama et al. 1981 (full reference give at top)
   */
  protected float [] calcColBC(final int lindex, final int levels[][]) {
    float colBC[] = new float[levels[lindex+1].length];
    GraphNode n;
   
    for(int i=0; i<levels[lindex+1].length; i++) {
      int sum=0;
      n = (GraphNode)m_nodes.elementAt(levels[lindex+1][i]);
     
View Full Code Here

TOP

Related Classes of weka.gui.graphvisualizer.GraphNode

Copyright © 2018 www.massapicom. 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.