Package org.graphstream.graph.implementations

Examples of org.graphstream.graph.implementations.DefaultGraph


     * framework.
     */
    @Test
    public void testJSONStreamEvents() {

  Graph g = new DefaultGraph("workspace0", false, true);

  JSONReceiver receiver = new JSONReceiver("localhost", 8080,
    "workspace0");

  ThreadProxyPipe pipe = receiver.getStream();

  pipe.addSink(g);

  g.addSink(new SinkAdapter() {
      /*
       * public void graphAttributeAdded(String sourceId, long timeId,
       * String attribute, Object value) { assertEquals(0, value);
       * assertEquals("graphAttribute", attribute); }
       *
       * public void graphAttributeChanged(String sourceId, long timeId,
       * String attribute, Object oldValue, Object newValue) {
       * assertTrue((Integer) newValue == 0 || (Integer) newValue == 1);
       * assertEquals("graphAttribute", attribute); }
       *
       * public void graphAttributeRemoved(String sourceId, long timeId,
       * String attribute) { assertEquals("graphAttribute", attribute); }
       *
       * public void nodeAttributeAdded(String sourceId, long timeId,
       * String nodeId, String attribute, Object value) { assertEquals(0,
       * value); assertEquals("nodeAttribute", attribute); }
       *
       * public void nodeAttributeChanged(String sourceId, long timeId,
       * String nodeId, String attribute, Object oldValue, Object
       * newValue) { assertTrue((Integer) newValue == 0 || (Integer)
       * newValue == 1); assertEquals("nodeAttribute", attribute); }
       *
       * public void nodeAttributeRemoved(String sourceId, long timeId,
       * String nodeId, String attribute) { assertEquals("nodeAttribute",
       * attribute); }
       *
       * public void edgeAttributeAdded(String sourceId, long timeId,
       * String edgeId, String attribute, Object value) { assertEquals(0,
       * value); assertEquals("edgeAttribute", attribute); }
       *
       * public void edgeAttributeChanged(String sourceId, long timeId,
       * String edgeId, String attribute, Object oldValue, Object
       * newValue) { assertTrue((Integer) newValue == 0 || (Integer)
       * newValue == 1); assertEquals("edgeAttribute", attribute); }
       *
       * public void edgeAttributeRemoved(String sourceId, long timeId,
       * String edgeId, String attribute) { assertEquals("edgeAttribute",
       * attribute); }
       */

      public void nodeAdded(String sourceId, long timeId, String nodeId) {
    assertTrue("node0".equals(nodeId) || "node1".equals(nodeId));
      }

      public void nodeRemoved(String sourceId, long timeId, String nodeId) {
    assertTrue("node0".equals(nodeId) || "node1".equals(nodeId));
      }

      public void edgeAdded(String sourceId, long timeId, String edgeId,
        String fromNodeId, String toNodeId, boolean directed) {
    assertEquals("edge", edgeId);
    assertEquals("node0", fromNodeId);
    assertEquals("node1", toNodeId);
    assertEquals(true, directed);
      }

      public void edgeRemoved(String sourceId, long timeId, String edgeId) {
    assertEquals("edge", edgeId);
      }

      public void graphCleared(String sourceId, long timeId) {

      }

      public void stepBegins(String sourceId, long timeId, double step) {
    assertEquals(1.1, step);
      }
  });

  new Thread() {

      @Override
      public void run() {
    Graph g = new MultiGraph("workspace0", false, true);

    JSONSender sender = new JSONSender("localhost", 8080,
      "workspace0");

    g.addSink(sender);

    Node node0 = g.addNode("node0");
    Edge edge = g.addEdge("edge", "node0", "node1", true);
    /*
     * node0.addAttribute("nodeAttribute", 0);
     * node0.changeAttribute("nodeAttribute", 1);
     * node0.removeAttribute("nodeAttribute");
     * edge.addAttribute("edgeAttribute", 0);
     * edge.changeAttribute("edgeAttribute", 1);
     * edge.removeAttribute("edgeAttribute");
     * g.addAttribute("graphAttribute", 0);
     * g.changeAttribute("graphAttribute", 1);
     * g.removeAttribute("graphAttribute");
     */
    g.stepBegins(1.1);
    g.removeEdge("edge");
    g.removeNode("node0");
    g.clear();
      }
  }.start();

  try {
      Thread.sleep(100);
View Full Code Here


import org.graphstream.graph.Node;
import org.graphstream.graph.implementations.DefaultGraph;

public class KevinBaconGame {
  public static void main(String[] args) throws FileNotFoundException {
    Graph graph = new DefaultGraph("KevinBacon", false, true);

    try (Scanner inNodeset = new Scanner(new FileInputStream("data\\movie_person_nodeset.txt"));
        Scanner inNetwork = new Scanner(new FileInputStream("data\\movie_person_network.txt"))) {
      buildGraph(graph, inNodeset, inNetwork);
      printGraphStatus(graph);
View Full Code Here

  Edge AB, BC, CD, DA;
  StyleSheet stylesheet;

  @Before
  public void setUp() {
    graph = new DefaultGraph("g1");

    A = graph.addNode("A");
    B = graph.addNode("B");
    C = graph.addNode("C");
    D = graph.addNode("D");
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

   */
  @Test
  public void testNetStreamEvents() {
    errors.clear();

    final Graph g1 = new DefaultGraph("G");
    NetStreamReceiver net = null;
    try {
      net = new NetStreamReceiver("localhost", 2002, debug);
    } catch (UnknownHostException e1) {
      fail(e1.toString());
    } catch (IOException e1) {
      fail(e1.toString());
    }

    ThreadProxyPipe pipe = net.getDefaultStream();

    pipe.addSink(g1);

    g1.addSink(new Sink() {

      public void graphAttributeAdded(String sourceId, long timeId,
          String attribute, Object value) {
        assertEquals(0, value);
        assertEquals("graphAttribute", attribute);
View Full Code Here

TOP

Related Classes of org.graphstream.graph.implementations.DefaultGraph

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.