Cannot Preserve Z-Coordinate in GEXF exporter #547

Closed
thylordroot opened this Issue Mar 6, 2012 · 1 comment

Projects

None yet

2 participants

@thylordroot

CPU: Intel Xeon 3.00GHz (x86_64)
GPU: NVidia N250GTS
OS: Ubuntu 110.4 (x86_64)
JVM: OpenJDK 1.6.0_22
Gephi: 0.8 Beta

Although Gephi can apparently read Z values for nodes, and these values are incorporated into the resulting model, the GEXF export tool does not seem to provide these values for the associated viz:position tags. For my particular needs, (and perhaps for others' needs) the preservation of these values is necessary. It would be helpful if we could do this.

In order to reproduce this issue, load a GEXF file with 3D coordinates present. The following is a basic example of such a file:

<?xml version='1.0' encoding='UTF-8'?>
<gexf xmlns:viz="http://www.gexf.net/1.1draft/viz"
    xmlns="http://www.gexf.net/1.2draft" version="1.2">
    <nodes>
        <node id='0' label='(0,0,0)'>
            <viz:position x='0' y='0' z='0'/>
        </node>

        <node id='1' label='(0,0,1)'>
            <viz:position x='0' y='0' z='1'/>
        </node>

        <node id='2' label='(0,1,0)'>
            <viz:position x='0' y='1' z='0'/>
        </node>

        <node id='3' label='(1,0,0)'>
            <viz:position x='1' y='0' z='0'/>
        </node>

    </nodes>
    <edges>
        <edge source='0' target='1'/>
        <edge source='0' target='2'/>
        <edge source='0' target='3'/>
    </edges>
</gexf>

Run "File->Export->Graph File", and select GEXF from the drop down menu. Click "options": notice that one of the options is to Export the position as an (x,y,z) triple. Now choose another name for the file, and choose "save" to export it. This is the output of the above GEXF file:

<?xml version="1.0" encoding="UTF-8"?>
<gexf xmlns="http://www.gexf.net/1.2draft" version="1.2" xmlns:viz="http://www.gexf.net/1.2draft/viz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd">
  <meta lastmodifieddate="2012-03-06">
    <creator>Gephi 0.8</creator>
    <description></description>
  </meta>
  <graph defaultedgetype="directed" timeformat="double" mode="dynamic">
    <nodes>
      <node id="0" label="(0,0,0)">
        <attvalues></attvalues>
        <viz:size value="10.0"></viz:size>
        <viz:position x="-0.25" y="-0.25"></viz:position>
        <viz:color r="153" g="153" b="153"></viz:color>
      </node>
      <node id="1" label="(0,0,1)">
        <attvalues></attvalues>
        <viz:size value="10.0"></viz:size>
        <viz:position x="-0.25" y="-0.25" z="1.0"></viz:position>
        <viz:color r="153" g="153" b="153"></viz:color>
      </node>
      <node id="2" label="(0,1,0)">
        <attvalues></attvalues>
        <viz:size value="10.0"></viz:size>
        <viz:position x="-0.25" y="0.75"></viz:position>
        <viz:color r="153" g="153" b="153"></viz:color>
      </node>
      <node id="3" label="(1,0,0)">
        <attvalues></attvalues>
        <viz:size value="10.0"></viz:size>
        <viz:position x="0.75" y="-0.25"></viz:position>
        <viz:color r="153" g="153" b="153"></viz:color>
      </node>
    </nodes>
    <edges>
      <edge source="0" target="1">
        <attvalues>
          <attvalue for="weight" value="1.0"></attvalue>
        </attvalues>
      </edge>
      <edge source="0" target="2">
        <attvalues>
          <attvalue for="weight" value="1.0"></attvalue>
        </attvalues>
      </edge>
      <edge source="0" target="3">
        <attvalues>
          <attvalue for="weight" value="1.0"></attvalue>
        </attvalues>
      </edge>
    </edges>
  </graph>
</gexf>

From the wording of the Options dialog, it appears that this is probably a bug. I propose one of the following solutions for this bug:

  • The "position (x,y,z)" option should specify the "z" attribute for viz:position, even if that Z value would never change
  • Selecting the "position" option would allow one to specify the desired coordinate components though an associated set of checkboxes.
  • Selecting the "position" option would allow one to specify whether or not the "Z" component should be included.

Without changing the wording of this parameter in the associated Options dialog, the first option would probably be best. The user is probably expecting "Position (x,y,z)" to output a triple, not a pair. The other two options may become useful in cases where one wants to shrink the output file in certain cases. Whether or not Z is initially provided could be determined by the range of the Z axis, or it a reasonable default value could be provided for it.

I have been authorized by my boss to fix this bug and submit it back, provided that it does not take too long. I wager this is probably a simple fix, and would be more than happy to contribute back to this great software. Thus, I would be willing to tackle this bug if the maintainers find it appropriate for me to do so.

@thylordroot

I had not noticed that my test case does produce a Z value for the one case where I have a nonzero Z-value. In light of that fact, the current output is probably fine. I did find a peculiar snippet of code in org.gephi.io.exporter.plugin.ExporterGEXF that filters out nodes at (0,0,0). This seems kind of peculiar to me: is (0,0,0) somehow not a valid node position? Thanks in advance!

@sheymann sheymann was assigned Mar 8, 2012
@sheymann sheymann closed this Mar 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment