Package org.graphstream.graph

Examples of org.graphstream.graph.Graph


    graph.getFirstAttributeOf("nonExisting", "nonExisting2", "nonExisting3");
  }
 
  @Test(expected=NullAttributeException.class)
  public void testElementValueAttributeNull3() {
    Graph graph = new MultiGraph("g");
    graph.setNullAttributesAreErrors(true);
    graph.getNumber("foo");
  }
View Full Code Here


    graph.getNumber("foo");
  }
 
  @Test(expected=NullAttributeException.class)
  public void testElementValueAttributeNull4() {
    Graph graph = new MultiGraph("g");
    graph.setNullAttributesAreErrors(true);
    graph.addAttribute("foo","ah ah ah");
    graph.getNumber("foo");
  }
View Full Code Here

    graph.getNumber("foo");
  }
 
  @Test(expected=NullAttributeException.class)
  public void testElementValueAttributeNull5() {
    Graph graph = new MultiGraph("g");
    graph.setNullAttributesAreErrors(true);
    graph.getLabel("foo");
  }
View Full Code Here

  public static void main(String[] args) throws UnknownHostException,
      IOException, InterruptedException {
    // ----- On the receiver side -----
    //
    // - a graph that will display the received events
    Graph g = new MultiGraph("G");
    g.display();
    // - the receiver that waits for events
    NetStreamReceiver net = new NetStreamReceiver(2001);
   
    net.setUnpacker(new Base64Unpacker());
    net.setDebugOn(false);
   
    // - received events end up in the "default" pipe
    ThreadProxyPipe pipe = net.getDefaultStream();
    // - plug the pipe to the sink of the graph
    pipe.addSink(g);

    // ----- The sender side (in another thread) ------
    //
    new Thread() {

      public void run() {
        // - the original graph from which events are generated
        Graph g = new MultiGraph("G");
        // - the sender
        NetStreamSender nsc = null;
        try {
          nsc = new NetStreamSender(2001);
        } catch (UnknownHostException e) {
          e.printStackTrace();
        } catch (IOException e) {
          e.printStackTrace();
        }
       
        nsc.setPacker(new Base64Packer());

       
        // - plug the graph to the sender so that graph events can be
        // sent automatically
        g.addSink(nsc);
        // - generate some events on the client side
        String style = "node{fill-mode:plain;fill-color:#567;size:6px;}";
        g.addAttribute("stylesheet", style);
        g.addAttribute("ui.antialias", true);
        g.addAttribute("layout.stabilization-limit", 0);
        for (int i = 0; i < 5000; i++) {
          g.addNode(i + "");
          if (i > 0) {
            g.addEdge(i + "-" + (i - 1), i + "", (i - 1) + "");
            g.addEdge(i + "--" + (i / 2), i + "", (i / 2) + "");
          }
        }
      }
    }.start();
View Full Code Here

    graph.getLabel("foo");
  }
 
  @Test(expected=NullAttributeException.class)
  public void testElementValueAttributeNull6() {
    Graph graph = new MultiGraph("g");
    graph.setNullAttributesAreErrors(true);
    graph.addAttribute("foo",5);
    graph.getLabel("foo");
  }
View Full Code Here

    graph.getLabel("foo");
  }

  @Test
  public void testElementMultiAttributes() {
    Graph graph = new MultiGraph("g1");

    Node A = graph.addNode("A");

    assertEquals("A", A.getId());
    assertEquals(0, A.getAttributeCount());

    // Arrays
View Full Code Here

    assertNotNull(A.getAttribute("array"));
  }

  @Test
  public void testElementUtilityMethods() {
    Graph graph = new MultiGraph("g1");

    Node A = graph.addNode("A");

    assertEquals("A", A.getId());
    assertEquals(0, A.getAttributeCount());

    // First attribute of.
View Full Code Here

    assertEquals(1, n);
  }

  @Test
  public void testElementIterables() {
    Graph graph = new MultiGraph("g1");

    Node A = graph.addNode("A");

    assertEquals("A", A.getId());
    assertEquals(0, A.getAttributeCount());

    // First attribute of.
View Full Code Here

    assertTrue(keys.contains("C"));
  }

  @Test
  public void testNullAttributes() {
    Graph graph = new MultiGraph("g1");

    graph.addAttribute("foo");
    graph.addAttribute("bar", (Object) null); // Yes an attribute with a
                          // null value, You can !

    assertTrue(graph.hasAttribute("foo"));
    assertTrue(graph.hasAttribute("bar"));

    graph.removeAttribute("foo");
    graph.removeAttribute("bar");

    assertFalse(graph.hasAttribute("foo"));
    assertFalse(graph.hasAttribute("bar"));
  }
View Full Code Here

  @Test
  public void test() {
    RMISink sink;
    RMISource source;

    Graph g1 = new DefaultGraph("g1");
    Graph g2 = new DefaultGraph("g2");

    try {
      LocateRegistry.createRegistry(1099);
    } catch (Exception e) {

    }

    try {
      String name = "__test_rmi_source";

      sink = new RMISink();
      g1.addSink(sink);

      source = new RMISource();
      source.addSink(g2);

      source.bind(name);
      sink.register("//localhost/" + name);
    } catch (RemoteException e) {
      fail();
    }

    Node A = g1.addNode("A");
    Node B = g1.addNode("B");
    Node C = g1.addNode("C");

    Edge AB = g1.addEdge("AB", "A", "B", false);
    Edge AC = g1.addEdge("AC", "A", "C", true);
    Edge BC = g1.addEdge("BC", "B", "C", false);

    A.addAttribute("int", 1);
    B.addAttribute("string", "test");
    C.addAttribute("double", 2.0);

    AB.addAttribute("points",
        (Object) (new double[][] { { 1, 1 }, { 2, 2 } }));
    LinkedList<Integer> list = new LinkedList<Integer>();
    list.add(1);
    list.add(2);
    AC.addAttribute("list", list);
    BC.addAttribute("boolean", true);

    // -----

    A = g2.getNode("A");
    B = g2.getNode("B");
    C = g2.getNode("C");

    assertNotNull(A);
    assertNotNull(B);
    assertNotNull(C);
    assertEquals(g2.getNodeCount(), 3);

    AB = g2.getEdge("AB");
    AC = g2.getEdge("AC");
    BC = g2.getEdge("BC");

    assertNotNull(AB);
    assertNotNull(AC);
    assertNotNull(BC);
    assertEquals(g2.getEdgeCount(), 3);

    assertEquals("A", AB.getNode0().getId());
    assertEquals("B", AB.getNode1().getId());
    assertEquals("A", AC.getNode0().getId());
    assertEquals("C", AC.getNode1().getId());
View Full Code Here

TOP

Related Classes of org.graphstream.graph.Graph

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.