[ https://issues.apache.org/jira/browse/TINKERPOP-2006?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16550832#comment-16550832 ]
ASF GitHub Bot commented on TINKERPOP-2006: ------------------------------------------- Github user twilmes commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/891#discussion_r204067177 --- Diff: gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLWriter.java --- @@ -218,20 +220,33 @@ private void writeTypes(final Map<String, String> identifiedVertexKeyTypes, final Map<String, String> identifiedEdgeKeyTypes, final XMLStreamWriter writer) throws XMLStreamException { // <key id="weight" for="edge" attr.name="weight" attr.type="float"/> - final Collection<String> vertexKeySet = getVertexKeysAndNormalizeIfRequired(identifiedVertexKeyTypes); + Collection<String> vertexKeySet = getVertexKeysAndNormalizeIfRequired(identifiedVertexKeyTypes); + Collection<String> edgeKeySet = getEdgeKeysAndNormalizeIfRequired(identifiedEdgeKeyTypes); + // in case vertex and edge may have the same attribute name, the key id in graphml have to be different + intersection = CollectionUtils.intersection(vertexKeySet, edgeKeySet); + // speeding-up later checks + if(intersection.isEmpty()){ + intersection = null; + } for (String key : vertexKeySet) { writer.writeStartElement(GraphMLTokens.KEY); - writer.writeAttribute(GraphMLTokens.ID, key); + if(intersection != null && intersection.contains(key)){ --- End diff -- Maybe here and below you could set a key variable once, something like: ``` String keyVal = key; if (!intersection.isEmpty() && intersection.contains(key)) { keyVal = key.concat(GraphMLTokens.VERTEX_SUFFIX) } writer.writeAttribute(GraphMLTokens.ID, key); ``` > GraphML serialization invalid if a vertex and edge have similar named property > ------------------------------------------------------------------------------ > > Key: TINKERPOP-2006 > URL: https://issues.apache.org/jira/browse/TINKERPOP-2006 > Project: TinkerPop > Issue Type: Bug > Components: io > Affects Versions: 3.3.3 > Reporter: Svante Schubert > Priority: Trivial > > I have created a graph using the Tinkerpop Graph and required for Gephi > visualization a property called color on edges and vertices to be coloured. > The current gremlin-core serialization creates the following two key elements > in GraphML > <key id="color" for="node" attr.name="color" attr.type="string"></key> > <key id="color" for="edge" attr.name="color" attr.type="string"></key> > the id attribute is an internal name, but have to be different. > I would suggest a patch to check for an intersection of the edge & vertices > keys and add for those keys an additional differentiating letter like: > <key id="colorV" for="node" attr.name="color" attr.type="string"></key> > <key id="colorE" for="edge" attr.name="color" attr.type="string"></key> > > Going to provide a pullrequest on GitHub. -- This message was sent by Atlassian JIRA (v7.6.3#76005)