If no dynamic graph, defaultedgetype is not written in the XML

Issue #17 resolved
George Vega Yon repo owner created an issue

Comments (8)

  1. Avitus

    Hallo George, before you start considering that bug, I would like to ask 2 questions that would allow me to better define the issue itself.

    1. Is it true that the data.frame for nodes has numeric 'Id' column and character 'Label' column? I tried with 'Label' column as factor and I got some issues with import.

    2. I use a data.frame called edges with 2 numerical columns for edges, originated from a data.frame through removal of NA's. I specify

    attributes(edges)$na.action <- NULL
    

    to remove the attribute na.action from the data.frame edges. Are you aware of bugs originated by NA's elimination?

    Remark: the following code works fine

    require(rgexf)
    vertices <- as.data.frame(cbind(seq(1,10),seq(1,10)))
    colnames(vertices) <- c('Id','Label')
    edges <- as.data.frame(cbind(c(5,1,2),c(1,1,3)))
    colnames(edges) <- c('Source','Target')
    write.gexf(output='testgex.gexf',nodes=vertices,edges=edges,
               defaultedgetype = "undirected")
    

    I checked the structure of my data.frames for nodes and edges and I followed the above example step by step (my data.frames are much more bigger, though) with no success.

    Either the import changes the source / target of edges reducing their number, or sometimes it even forgets the first edge...only in the data laboratory window!

    Thank you very much for your support.

    A.

  2. Avitus

    Hallo George, referring to my comment above, the XLM code of the R code is simply

    <?xml version="1.0" encoding="UTF-8"?>
    <gexf xmlns="http://www.gexf.net/1.2draft" xmlns:viz="http://www.gexf.net/1.1draft/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" version="1.2">
      <meta lastmodifieddate="2014-02-27">
        <creator>NodosChile</creator>
        <description>A graph file writing in R using "rgexf"</description>
        <keywords>gexf graph, NodosChile, R, rgexf</keywords>
      </meta>
      <graph mode="static">
        <nodes>
          <node id="1" label="1"/>
          <node id="2" label="2"/>
          <node id="3" label="3"/>
          <node id="4" label="4"/>
          <node id="5" label="5"/>
          <node id="6" label="6"/>
          <node id="7" label="7"/>
          <node id="8" label="8"/>
          <node id="9" label="9"/>
          <node id="10" label="10"/>
        </nodes>
        <edges>
          <edge id="0" source="5" target="1" weight="1.0"/>
          <edge id="1" source="1" target="1" weight="1.0"/>
          <edge id="2" source="2" target="3" weight="1.0"/>
        </edges>
      </graph>
    </gexf>
    

    All nodes and edges are properly described. I really think my problem is just a bug hidden in Gephi, not in your package. I hope it helps! :-)

    *** A small question

    With much more complicated graphs, I have noticed that the XML output of write.gexf can present list of nodes in arbitrary order. For example

     <?xml version="1.0" encoding="UTF-8"?>
    <gexf xmlns="http://www.gexf.net/1.2draft" xmlns:viz="http://www.gexf.net/1.1draft/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" version="1.2">
      <meta lastmodifieddate="2014-02-27">
        <creator>NodosChile</creator>
        <description>A graph file writing in R using "rgexf"</description>
        <keywords>gexf graph, NodosChile, R, rgexf</keywords>
      </meta>
      <graph mode="static">
        <nodes>
          <node id="1" label="#data: 16 ---- I write something here"/>
          <node id="12" label="#data: 1 ---- I write something here"/>
          <node id="20" label="#data: 3 ---- I write something here"/>
          <node id="21" label="#data: 4 ---- I write something here"/>
          <node id="22" label="#data: 1 ---- I write something here"/>
          <node id="23" label="#data: 1 ---- I write something here"/>
          <node id="24" label="#data: 1 ---- I write something here"/>
          <node id="25" label="#data: 1 ---- I write something here"/>
          <node id="26" label="#data: 1 ---- I write something here"/>
          <node id="2" label="#data: 1 ---- I write something here"/>
          <node id="3" label="#data: 2 ---- I write something here"/>
          <node id="4" label="#data: 11 ---- I write something here"/>
          <node id="5" label="#data: 1 ---- I write something here"/>
          <node id="6" label="#data: 5 ---- I write something here"/>
          <node id="7" label="#data: 3 ---- I write something here"/>
          <node id="8" label="#data: 2 ---- I write something here"/>
          <node id="9" label="#data: 2 ---- I write something here"/>
          <node id="10" label="#data: 1 ---- I write something here"/>
          <node id="11" label="#data: 2 ---- I write something here"/>
          <node id="13" label="#data: 23 ---- I write something here"/>
          <node id="14" label="#data: 11 ---- I write something here"/>
          <node id="15" label="#data: 1 ---- I write something here"/>
          <node id="16" label="#data: 6 ---- I write something here"/>
          <node id="17" label="#data: 3 ---- I write something here"/>
          <node id="18" label="#data: 1 ---- I write something here"/>
          <node id="19" label="#data: 4 ---- I write something here"/>
        </nodes>
        <edges>
          <edge id="0" source="5" target="1" weight="1.0"/>
          <edge id="1" source="2" target="4" weight="1.0"/>
          <edge id="2" source="6" target="2" weight="1.0"/>
          <edge id="3" source="1" target="7" weight="1.0"/>
          <edge id="4" source="7" target="3" weight="1.0"/>
          <edge id="5" source="3" target="5" weight="1.0"/>
          <edge id="6" source="3" target="5" weight="1.0"/>
          <edge id="7" source="4" target="6" weight="1.0"/>
        </edges>
      </graph>
    </gexf>
    

    This happens to me when labels of nodes are alphanumeric (of character type in R).

    Is this ok or is it considered as a bug in rgexf? Did rgexf read the data in a wrong way? I remark that all nodes are present, with correct id and label. It is just their order which is permuted.

    Thank you!

    A.

  3. George Vega Yon reporter

    Dear Andrea (that's your name, right?),

    For the first question, it turns out that it is not a requirement that the Ids of the nodes should be numeric, but it is a requirement that you should provide write.gexf with a two column matrix/data.frame. In the case of including factor variables, write.gexf has an option for factor variables (keepFactors) which tells the function whereas to interpret factors as numbers or as characters.

    On your second question, the truth is that I'm not sure what are you asking. If you provide me with a more detailed example (code lines and, if possible, data) I will be happy to help you.

    About the bug itself. It is a bug, please note that where it says <graph mode="static"> it should say <graph mode="static" defaultedgetype="undirected"> (small bug thou =))

    Finally, on your concern of the order of apperance of the nodes, I will give it a look, still it is no problem for Gephi =).

    George

  4. Avitus

    Hallo George, thank you for your answer and sorry for the late reply. I see, it is a small bug :-) You found the answer to my question, great!

    Is it possible for me to correct / solve it "manually"? If not, are you thinking of a new release of rgexf?

    Regarding the order of appearance of nodes, it was just a curiosity dictated by paranoia :-)

    Thank you for your interest and support.

    A.

  5. Avitus

    Hallo George, thank you for your support! Where can I find the updated version of rgexf, if any?

    Regards, A.

  6. George Vega Yon reporter

    I'll try to publish it in a few hours, not in CRAN thou. Check the package website in about one hour.

    George Vega Yon +56 9 7 647 2552 http://ggvega.cl

  7. Log in to comment