If you want to have the MetaNodes plugin to show only one edge between the MetaNodes after they are collapsed, you can use this hack.

(from a post from Iliana)

Open up the class:

metaNodeViewer.model.AbstractMetaNodeModeler

And then search for the string Kris. This will take you to a commented-out section of the code that Iliana wrote for a person named Kris who wanted edge collapsing. Uncomment this part of the code and comment the part on top of it so that it looks like this:

COMMENT THIS OUT:

   1    for ( int ci = 0; ci < connectingEdgesRindices.length; ++ci ) {
   2       edges_to_restore.add( connectingEdgesRindices[ci] );
   3    }
   4 

UNCOMMENT THIS:

   1       //----------- For Kris Gonsalus:------------------------
   2       // Kris has a graph with 78 nodes, and > 2000 edges, so she
   3       // wants to see only one edge between metanodes...
   4 
   5        edges_to_restore.add(connectingEdgesRindices[0]);
   6 
   7       //------------------------------------------------------
   8 

Compile, make new jar, and load into C2.1. This is a hack! But it should work.

After this, I (MarcioSilva) wanted to have an edge attribute that saves the number of edge that each "MetaEdge" is representing. I did this:

in metaNodeViewer.model.AbstractMetaNodeModeler:

   1 //----------- For Kris Gonsalus:------------------------
   2 // Kris has a graph with 78 nodes, and > 2000 edges, so she
   3 // wants to see only one edge between metanodes...
   4 edges_to_restore.add(connectingEdgesRindices[0]);
   5          
   6 // path by mrsva
   7 int edge = connectingEdgesRindices[0];
   8 String attr = new String("metaedgesize");
   9 Integer value = new Integer(connectingEdgesRindices.length);
  10 cy_network.setEdgeAttributeValue(edge, attr, value);
  11 // end mrsva's path
  12 

and in metaNodeViewer.data.SimpleMetaNodeAttributesHandler class:

from line 269:

   1 for (int i = 0; i < allAttrNames.length; i++) {
   2         String attrName = allAttrNames[i];
   3         if (attrName.equals("metaedgesize"))    // added by mrsva
   4                 continue; // reserved           // added by mrsva
   5         if (attrName.equals("interaction"))
   6                 continue; // reserved
   7         if (attrName.equals(Semantics.CANONICAL_NAME))
   8                 continue; // reserved
   9 

and from line 345 (or 343 if the modification above was not made):

   1 for (int i = 0; i < attributes.length; i++) {
   2         if (attributes[i].equals(Semantics.CANONICAL_NAME)
   3                         || attributes[i].equals(Semantics.COMMON_NAME)
   4                         || attributes[i].equals("metaedgesize")) { // added by mrsva
   5                 continue;
   6         } 
   7 

You can get the complete file SimpleMetaNodeAttributesHandler.java with the modifications here: SimpleMetaNodeAttributesHandler.java

A final hack (also from Iliana) is in the main cytoscape.jar file to avoid some exceptions in the execution of the plugin. There are 2 fixes.

As the fixes are both in the Cytoscape core, you will need to download the source for Cytoscape 2.1 (NOT the source in CVS, which is under development!). To get the source code of Cytoscape 2.1 go to Cytoscape download page.

The fixes are very easy:

  1. In class

    {{{cytoscape.visual.VisualMappingManager }}} modify method

     applyEdgeAppearances( CyNetwork network, CyNetworkView network_view )
    to do this:
       1  EdgeAppearanceCalculator edgeAppearanceCalculator = visualStyle.getEdgeAppearanceCalculator();
       2      for (Iterator i = network_view.getEdgeViewsIterator(); i.hasNext(); ) {
       3          EdgeView edgeView = (EdgeView)i.next();
       4  
       5          //----------- NEW --------------------------------------
       6          if(edgeView == null){
       7              continue;
       8          }
       9          //----------------------------------------------------------
      10          // other code stays the same...
      11 
    
  2. In class
     cytoscape.view.GraphViewController
    modify method
     graphPerspectiveChanged (GraphPerspectiveChangeEvent event)
    to do this:
       1  public void graphPerspectiveChanged (GraphPerspectiveChangeEvent event){
       2      //TODO: Remove
       3      //System.out.println("In GraphViewController.graphPerspectiveChanged(), event = " + event);
       4      // ------------------- NEW -------------------------------------------------------
       5      // Weird. The source can be a GraphPerspective, or a RootGraph
       6      // even though the name of the event is GraphPerspectiveChangeEvent
       7      Object source = event.getSource();
       8  
       9      if(!(source instanceof GraphPerspective)){
      10          //TODO: What to do here???
      11          System.out.println("GraphViewController.graphPerspectiveChanged(): The source of the event is not a  GraphPerspective!. Event = " + event);
      12          return;
      13      }
      14      //-------------------------------------------------------------------------------------
      15      // code after this stays the same...
      16 
    

MetaNodesOneEdgeHack (last edited 2009-02-12 01:04:15 by localhost)

MoinMoin Appliance - Powered by TurnKey Linux