Correlations library

Hi, First post overhere.

Any idea about correlations library for processing http://www.muehlseife.de/ It is a really awesome tool. Right now i am trying to delete nodes, but i havent succeed. Maybe there is other tool - library i can use for the same purpose = GUI noded based Any help i will appreciate it.

Best Regards.

Answers

  • @trafalmejo Do you have an example sketch to share? What are you using the library for? (will help to know what to recommend).

    What have you tried to fix your problem?

    • assigning a Node = null?
    • Node.showIcon(false)?
    • Graph?
    • CorrelationsEvent and the NODE_REMOVED constant?

    etc. etc.

    Check out the library javadoc ...and if you are really stuck, also try contacting the author directly!

  • Thanks Jeremy,

    Unfortunately, nothing works. This is my code for example (library sample): `import muehlseife.correlations.*;

    Graph myGraph; //Add an Edge by pressing ALT and dragging from start to target node!!!

    void setup() { size(800, 600);

    myGraph = new Graph(this); //create a new Graph //myGraph.fixColor = true; myGraph.registerCorrelationsEvent(this); //myGraph.showLabels = true;

    //create 3 Nodes myGraph.put("node 1", new Node(100, 100, 35, 70, color(255, 125, 0))); myGraph.put("node 2", new Node(230, 160, 45, 90, color(230))); myGraph.put("node 3", new Node(360, 80, 35, 70, color(0, 125, 255)));

    //add edges between the nodes myGraph.get("node 2").addEdge(myGraph.get("node 3"), 1f).showSlider = true; ; myGraph.get("node 2").addEdge(myGraph.get("node 1"), 1f).showSlider = true; ; myGraph.get("node 1").addEdge(myGraph.get("node 2"), 1f).showSlider = true; ; myGraph.get("node 1").addEdge(myGraph.get("node 3"), 0.7f).showSlider = true; }

    void draw() { background(255); myGraph.render(); }

    void correlationsEvent(CorrelationsEvent event) { switch (event.getID()) { case CorrelationsEvent.EDGE_ADDED: Edge edge = event.getEdge(); edge.setSlider(true, -1, 1, 0, 0); edge.setColor(new int[] { color(255, 0, 0), color(0), color(0) } ); edge.value = 0f; break; case CorrelationsEvent.EDGE_REMOVED: background(0); println("PERROS"); break; }

    println(event.toString()); } public void keyPressed() { if (key == CODED) { if (keyCode == UP) { myGraph.get("node 2").showIcon = false; myGraph.get("node 2").showIcon = null; } if (keyCode == DOWN) { Node a = myGraph.get("node 1"); a = null; // There is no way to edit the node } if (keyCode == LEFT) { myGraph.put("node 1", new Node(null)); //null pointer exception
    } } } `

    I have tried test differente ways with the keys UP, DOWN and LEFT in order to delete any node. According with you suggestions:

    1-assigning a Node = null? i dont know how to access to the nodes. It is not described in the javadoc

    2-Node.showIcon(false)? This is an attribute which seems doesnt have effect.

    3-Graph? It doesnt have any method to remove nodes

    4-CorrelationsEvent and the NODE_REMOVED constant? It detects events as EDGE ADDED OR REMOVED, But i dont know how to delete nodes, so this event have never been triggered.

    When i do: myGraph.put("node 1", new Node(this)); It creates a new node and deletes all the existing edges, but it didnt delete anything

    myGraph.put("node 1", null); It gives me a Nullpointer Exception

    Any other idea,

    Thanks!

  • Please edit your post and format the code with CTRL-o to aid other forum members in reading and testing your code.

  • Thanks Jeremy,

    Unfortunately, nothing works. This is my code for example (library sample):

    import muehlseife.correlations.*;
    
    Graph myGraph; //Add an Edge by pressing ALT and dragging from start to target node!!!
    
    void setup() { size(800, 600);
    
    myGraph = new Graph(this); //create a new Graph //myGraph.fixColor = true; myGraph.registerCorrelationsEvent(this); //myGraph.showLabels = true;
    
    //create 3 Nodes myGraph.put("node 1", new Node(100, 100, 35, 70, color(255, 125, 0))); myGraph.put("node 2", new Node(230, 160, 45, 90, color(230))); myGraph.put("node 3", new Node(360, 80, 35, 70, color(0, 125, 255)));
    
    //add edges between the nodes myGraph.get("node 2").addEdge(myGraph.get("node 3"), 1f).showSlider = true; ; myGraph.get("node 2").addEdge(myGraph.get("node 1"), 1f).showSlider = true; ; myGraph.get("node 1").addEdge(myGraph.get("node 2"), 1f).showSlider = true; ; myGraph.get("node 1").addEdge(myGraph.get("node 3"), 0.7f).showSlider = true; }
    
    void draw() { background(255); myGraph.render(); }
    
    void correlationsEvent(CorrelationsEvent event) { switch (event.getID()) { case CorrelationsEvent.EDGE_ADDED: Edge edge = event.getEdge(); edge.setSlider(true, -1, 1, 0, 0); edge.setColor(new int[] { color(255, 0, 0), color(0), color(0) } ); edge.value = 0f; break; case CorrelationsEvent.EDGE_REMOVED: background(0); println("PERROS"); break; }
    
    println(event.toString()); } public void keyPressed() { if (key == CODED) { if (keyCode == UP) { myGraph.get("node 2").showIcon = false; myGraph.get("node 2").showIcon = null; } if (keyCode == DOWN) { Node a = myGraph.get("node 1"); a = null; // There is no way to edit the node } if (keyCode == LEFT) { myGraph.put("node 1", new Node(null)); //null pointer exception
    } } } 
    

    I have tried test differente ways with the keys UP, DOWN and LEFT in order to delete any node. According with you suggestions:

    1-assigning a Node = null? i dont know how to access to the nodes. It is not described in the javadoc

    2-Node.showIcon(false)? This is an attribute which seems doesnt have effect.

    3-Graph? It doesnt have any method to remove nodes

    4-CorrelationsEvent and the NODE_REMOVED constant? It detects events as EDGE ADDED OR REMOVED, But i dont know how to delete nodes, so this event have never been triggered.

    When i do: myGraph.put("node 1", new Node(this)); It creates a new node and deletes all the existing edges, but it didnt delete anything

    myGraph.put("node 1", null); It gives me a Nullpointer Exception

    Any other idea,

    Thanks!

  • edited October 2016 Answer ✓

    It sounds like you should try to contact the library author -- this might be a feature request for Graph to support e.g. myGraph.remove("node 2").

    A workaround:

    If you have only adders and getters but no deleters, you can create deleting by writing a custom copy function as a substitute for delete. The function takes an original Graph object and a node to delete. It copies each node (except the one you don't want) and each edge into a new Graph object. It returns the new Graph object, which you use to replace the old one.

    myGraph = deleteNode(myGraph, "node 2");
    
  • Jeremy Thanks a lot! It worked perfectly. I suggested the myGraph.remove("node 2") as you told me anyway. Solved

  • @trafalmejo -- great to hear!

    If you think it might be useful to others and you are willing/able to share, posting the code for your custom delete function here might help future Correlations library users.

Sign In or Register to comment.