Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import of GraphML: Specific attribute IDs are dismissed #1575

Closed
klastoferix opened this issue Oct 4, 2016 · 1 comment
Closed

Import of GraphML: Specific attribute IDs are dismissed #1575

klastoferix opened this issue Oct 4, 2016 · 1 comment

Comments

@klastoferix
Copy link

In the GraphML Importer (ImporterGraphML.java) some attribute ids like "xpos" and "x" or "label" and "d3" seem to be considered equivalent. If you specify for example an attribute d3 in a GraphML file and import that file, the values of this attribute are only available under the id label. If you specify multiple attributes that are considered equivalent by Gephi (label and d3), one of them seems to be dismissed, which is inconsistent with the GraphML specification.

Example:

When I try to import a graphml file [1] that specifies the attributes d3 for nodes and d7 for edges with the gephi toolkit as shown in the java snippet [2], the ids d3 and d7 throw exceptions, while I can get the values via the id label.
Further, if I create an attribute with the id label, n.getAttribute("label") returns the value for label but n.getAttribute("d3") still throws an exception, so I have no access to the attribute d3.

[1] examplefile.graphml

<?xml version="1.0" encoding="utf-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
    <key attr.name="edgeData" attr.type="string" for="edge" id="someIdForEdge"/>
    <key attr.name="d7Data" attr.type="string" for="edge" id="d7"/>
    <key attr.name="nodeData" attr.type="string" for="node" id="someIdForNode"/>
    <key attr.name="d3Data" attr.type="string" for="node" id="d3"/>
    <graph edgedefault="directed">
        <node id="n1">
            <data key="someIdForNode">Some Node Data</data>
            <data key="d3">D3 Data</data>
        </node>
        <edge source="n1" target="n1">
            <data key="someIdForEdge">Some Edge Data</data>
            <data key="d7">D7 Data</data>
        </edge>
    </graph>
</graphml>

[2] Java Snippet

//Init a project and a workspace
ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
pc.newProject();
Project project = pc.getCurrentProject();
Workspace workspace = project.getLookup().lookup(WorkspaceProvider.class).getCurrentWorkspace();

//Import file
ImportController importController = Lookup.getDefault().lookup(ImportController.class);
FileImporter fileimp = importController.getFileImporter("graphml");
Container container = importController.importFile(new File("data/examplefile.graphml"));
importController.process(container, new DefaultProcessor(), workspace);

//Print the column values
GraphModel model = Lookup.getDefault().lookup(GraphController.class).getGraphModel(workspace);

System.out.println("----------------\nColumns for node:\n----------------");

for(Node n : model.getGraph().getNodes())
{
    System.out.println("label:" + n.getAttribute("label"));
    System.out.println("someidfornode:" + n.getAttribute("someidfornode"));

    //Throws an error
    try
    {
        System.out.println("d3:" + n.getAttribute("d3"));
    }
    catch(Exception ex)
    {
        ex.printStackTrace();
    }
}

System.out.println("----------------\nColumns for edge:\n----------------");

for(Edge e : model.getGraph().getEdges())
{
    System.out.println("label:" + e.getAttribute("label"));
    System.out.println("someidforedge:" + e.getAttribute("someidforedge"));

    //Throws an error
    try
    {
        System.out.println("d7:" + e.getAttribute("d7"));
    }
    catch(Exception ex)
    {
        ex.printStackTrace();
    }
}

Output:

----------------
Columns for node:
----------------
label:D3 Data
someidfornode:Some Node Data
java.lang.IllegalArgumentException: The column 'd3' is not found
    at org.gephi.graph.impl.ElementImpl.checkColumnExists(ElementImpl.java:710)
    at org.gephi.graph.impl.ElementImpl.getAttribute(ElementImpl.java:89)
----------------
Columns for edge:
----------------
label:D7 Data
someidforedge:Some Edge Data
java.lang.IllegalArgumentException: The column 'd7' is not found
    at org.gephi.graph.impl.ElementImpl.checkColumnExists(ElementImpl.java:710)
    at org.gephi.graph.impl.ElementImpl.getAttribute(ElementImpl.java:89)
@eduramiba
Copy link
Member

Related #1719

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants