Skip to content

Adding custom properties to edge or node in yED changes .graphml key id for description #128

Open

Description

@DarrenHowatt

Within the class YEdContextFactory the methods addVertices and addEdges retrieve the description by calling getStringValue on the DataType with data.getKey().equals("d5") and data.getKey().equals("d9") respectively.

However, if a custom node or edge property is added to the graph in yED the key ids will no longer be "d5" or "d9".

.graphml with no custom properties:

  <key attr.name="Description" attr.type="string" for="graph" id="d0"/>
  <key for="port" id="d1" yfiles.type="portgraphics"/>
  <key for="port" id="d2" yfiles.type="portgeometry"/>
  <key for="port" id="d3" yfiles.type="portuserdata"/>
  <key attr.name="url" attr.type="string" for="node" id="d4"/>
  <key attr.name="description" attr.type="string" for="node" id="**d5**"/>
  <key for="node" id="d6" yfiles.type="nodegraphics"/>
  <key for="graphml" id="d7" yfiles.type="resources"/>
  <key attr.name="url" attr.type="string" for="edge" id="d8"/>
  <key attr.name="description" attr.type="string" for="edge" id="**d9**"/>
  <key for="edge" id="d10" yfiles.type="edgegraphics"/>

.graphml with custom properties:

 <key attr.name="Description" attr.type="string" for="graph" id="d0"/>
  <key for="port" id="d1" yfiles.type="portgraphics"/>
  <key for="port" id="d2" yfiles.type="portgeometry"/>
  <key for="port" id="d3" yfiles.type="portuserdata"/>
  <key attr.name="myCustomNodeProp" attr.type="string" for="node" id="d4">
    <default><![CDATA[Hello]]></default>
  </key>
  <key attr.name="url" attr.type="string" for="node" id="d5"/>
  <key attr.name="description" attr.type="string" for="node" id="**d6**"/>
  <key for="node" id="d7" yfiles.type="nodegraphics"/>
  <key for="graphml" id="d8" yfiles.type="resources"/>
  <key attr.name="myCustomEdgeProp" attr.type="string" for="edge" id="d9">
    <default><![CDATA[World]]></default>
  </key>
  <key attr.name="url" attr.type="string" for="edge" id="d10"/>
  <key attr.name="description" attr.type="string" for="edge" id="**d11**"/>
  <key for="edge" id="d12" yfiles.type="edgegraphics"/>

Activity

  1. KristianKarl-zz commented on Mar 5, 2017

    @KristianKarl-zz
    Contributor

    Yeah, that's a problem with yWorks graphml file format.

    • The short term solution is not to use custom properties.
    • The long term solution is switching to the new json file format
  2. DarrenHowatt commented on Mar 6, 2017

    @DarrenHowatt
    ContributorAuthor

    Would you mind if I tried to implement a fix?

  3. KristianKarl-zz commented on Mar 7, 2017

    @KristianKarl-zz
    Contributor

    That would be great. Give it a shot!
    What would your solution look like? On a higher level.

  4. DarrenHowatt commented on Mar 7, 2017

    @DarrenHowatt
    ContributorAuthor

    By high level i hope this isn't too high :)

    document.getGraphml().getKeyArray()
    String key =data.getKey();
    Lookup key
    make sure !isSetYfilesType
    get the attrib.name and default if it exists
    then vertex.setProperty =(attr.name,value or default)

    but am trying to figure out how to be fast :)

    then same for edges.

    I figure then any custom attribute can be used and will be part of json

    thoughts?

  5. DarrenHowatt commented on Mar 7, 2017

    @DarrenHowatt
    ContributorAuthor

    If you can help me just get for-"node" attributes I would feel more comfortable knowing that all keys would have a hit. Sample below will include for=edge also.
    I hate lookups when I know there are items I am not interested in.

    document.selectPath(NAMESPACE + "$this/xq:graphml/xq:key");

    I have tried multiple variations of:
    document.selectPath(NAMESPACE + "$this/xq:graphml/xq:key[@for=node]");
    with no luck

  6. KristianKarl-zz commented on Mar 7, 2017

    @KristianKarl-zz
    Contributor

    Looks good. Regards to your question.
    What about starting with adding a couple of unit tests. Also add a couple of yEd graphml files with single and multiple custom properties for vertices and edges.

    Do that in the graphwalker-io module.
    You could add the tests into org.graphwalker.io.factory.yed.YEdContextFactoryTest class.
    Add the graphml files into ./graphwalker-io/src/test/resources/graphml folder

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions