Package org.graphstream.graph.implementations

Examples of org.graphstream.graph.implementations.MultiGraph


    basicPanel.setLayout(new BoxLayout(basicPanel, BoxLayout.Y_AXIS));
   
    //result-panel
    JPanel resultPanel = createResultPanel();
    //graphstream-panel
    Graph g = new MultiGraph("g");
    g.addAttribute("ui.quality");
    g.addAttribute("ui.antialias");
    g.addAttribute("ui.stylesheet", styleSheet);

    JPanel graphStreamPanel = new JPanel();
    graphStreamPanel.setPreferredSize(new Dimension((int)(800*scaling),(int)(460*scaling)));
    graphStreamPanel.setBackground(Color.WHITE);
   
 
View Full Code Here


    private JSONReceiver receiver;

    public void findCommunities() throws IOException, GraphParseException {

  graph = new MultiGraph("Communities", false, true);
  viewer = graph.display(false);
  fromViewer = viewer.newThreadProxyOnGraphicGraph();

  layout = new LinLog(false);
  layout.configure(a, r, true, force);
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", false, true);
  g.display();
  // - the receiver that waits for events
  JSONReceiver receiver = new JSONReceiver("localhost", 8080,
    "workspace0");
  receiver.setDebug(true);
  // - received events end up in the "default" pipe
  ThreadProxyPipe pipe = receiver.getStream();
  // - 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
    JSONSender sender = new JSONSender("localhost", 8080,
      "workspace0");
    // - plug the graph to the sender so that graph events can be
    // sent automatically
    g.addSink(sender);
    // - 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 < 50; 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

* @author Min WU
*/
public class GraphSender {

    public static void main(String args[]) {
  Graph graph = new MultiGraph("Tutorial 1 GraphSender");

  graph.display();

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

  // plug the graph to the sender so that graph events can be
  // sent automatically
  graph.addSink(sender);

  // generate the graph on the client side
  String style = "node{fill-mode:plain;fill-color:#567;size:6px;}";
  graph.addAttribute("stylesheet", style);
  graph.addAttribute("ui.antialias", true);
  graph.addAttribute("layout.stabilization-limit", 0);
  for (int i = 0; i < 500; i++) {
      graph.addNode(i + "");
      if (i > 0) {
    graph.addEdge(i + "-" + (i - 1), i + "", (i - 1) + "");
    graph.addEdge(i + "--" + (i / 2), i + "", (i / 2) + "");
      }
  }
    }
View Full Code Here

  receiver.setDebug(true);

  ThreadProxyPipe pipe = receiver.getStream();

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

  pipe.addSink(g);

  g.addSink(new SinkAdapter() {

      public void graphAttributeAdded(String sourceId, long timeId,
        String attribute, Object value) {
    System.out.println("Graph Attribtue Added");
      }
  });

  new Thread() {

      public void run() {

    Graph g = new MultiGraph("workspace0", false, true);
    JSONSender sender = new JSONSender("localhost", 8080,
      "workspace0");

    sender.setDebug(true);

    g.addSink(sender);

    g.addAttribute("attribute", "foo");
    g.changeAttribute("attribute", false);

    Edge e = g.addEdge("AB", "A", "B");
    e.addAttribute("attribute", "foo");
    e.changeAttribute("attribute", false);
    Node n = e.getNode0();
    n.addAttribute("attribute", "foo");
    n.changeAttribute("attribute", false);
View Full Code Here

     * Test multiple senders running on separated threads.
     */
    // @Test
    public void testJSONStreamMultiThreadSenders() {

  Graph g = new MultiGraph("workspace0");

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

  // receiver.setDebug(true);

  ThreadProxyPipe pipe = receiver.getStream();

  pipe.addSink(g);

  launchClient("localhost", 8080, "workspace0", "0");
  launchClient("localhost", 8080, "workspace0", "1");

  for (int i = 0; i < 10; i++) {
      pipe.pump();

      try {
    Thread.sleep(100);
      } catch (InterruptedException e) {
    e.printStackTrace();
      }
  }

  pipe.pump();

  // assertEquals("workspace0", g.getAttribute("id"));
  assertEquals(180, g.getNodeCount());
    }
View Full Code Here

  new Thread() {

      @Override
      public void run() {

    Graph g = new MultiGraph(workspace + prefix);

    JSONSender sender = new JSONSender(host, port, workspace);

    g.addSink(sender);

    g.addAttribute("id", workspace);

    for (int i = 0; i < 30; i++) {
        g.addNode(prefix + i + "_1");
        g.addNode(prefix + i + "_0");
        g.addNode(prefix + i + "_2");
        try {
      Thread.sleep(1);
        } catch (InterruptedException e) {
      e.printStackTrace();
        }
View Full Code Here

  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

    public static void main(String[] args) {
  // TODO Auto-generated method stub
  // ----- On the receiver side -----
  //
  // a graph that will display the received events
  Graph g = new MultiGraph("G", false, true);
  g.display();
  // the receiver that waits for events
  JSONReceiver receiver = new JSONReceiver("localhost", 8080,
    "workspace0");
  receiver.setDebug(true);
  ThreadProxyPipe pipe = receiver.getStream();
View Full Code Here

    new DemoLayoutAndViewer();
  }

  public DemoLayoutAndViewer() {
    boolean loop = true;
    Graph graph = new MultiGraph("test");
    Viewer viewer = new Viewer(new ThreadProxyPipe(graph));
    ProxyPipe fromViewer = viewer.newThreadProxyOnGraphicGraph();
    LinLog layout = new LinLog(false);
   
    layout.configure(a, r, true, force);

    graph.addAttribute("ui.antialias");
    graph.addAttribute("ui.stylesheet", styleSheet);
    fromViewer.addSink(graph);
    viewer.addDefaultView(true);
    graph.addSink(layout);
    layout.addAttributeSink(graph);

    FileSource dgs = GRAPH.endsWith(".gml") ? new FileSourceGML() : new FileSourceDGS();

    dgs.addSink(graph);
    try {
      dgs.begin(getClass().getResourceAsStream(GRAPH));
      for (int i = 0; i < 5000 && dgs.nextEvents(); i++) {
//        fromViewer.pump();
//        layout.compute();
//        sleep(100);
      }
      dgs.end();
    } catch (IOException e1) {
      e1.printStackTrace();
      System.exit(1);
    }
   
    System.out.println("Finished creating the graph.");

    while (loop) {
      fromViewer.pump();

      if (graph.hasAttribute("ui.viewClosed")) {
        loop = false;
      } else {
        //sleep(1000);       
        layout.compute();
        findCommunities(graph, 1.3);
View Full Code Here

TOP

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

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.