Identifying graph schema in GraphML

Defining the vertices and edges along with their properties is a critical first step in creating a graph database in GraphML. GraphML is an XML format that identifies vertices and edges. The first step in defining a graph in GraphML involves defining the vertex and edge properties. Note that a drawback of using GraphML is that indexes cannot be defined.

  1. The GraphML header in the file identifies XML information:

    <?xml version='1.0' encoding='UTF-8'?>
    <graphml xmlns=""
  2. Create a graph instance to identify schema in a new file.

    <graph id="graph" edgedefault="directed">
  3. Define the vertex properties.

    <key id="labelV" for="node""labelV" attr.type="string"/>
    <key id="id" for="node""id" attr.type="int" />
    <key id="aname" for="node""aname" attr.type="string"/>
    <key id="gender" for="node""gender" attr.type="string"/>
    <key id="recipeTitle" for="node""recipeTitle" attr.type="string" />
    <key id="instructions" for="node""instructions" attr.type="string" />
    <key id="bookTitle" for="node""bookTitle" attr.type="string" />
    <key id="publishDate" for="node""publishDate" attr.type="int" />
    <key id="ISBN" for="node""ISBN" attr.type="string" />
    <key id="iName" for="node""iName" attr.type="string" />
    <key id="mealTitle" for="node""mealTitle" attr.type="string"/>
    <key id="mCreateDate" for="node""mCreateDate" attr.type="string"/>
    <key id="calories" for="node""calories" attr.type="int"/>
    <key id="revname" for="node""revname" attr.type="string"/>

    The property with id labelV is always defined, as each vertex has a vertex label. Additional vertex properties are defined with an ID, attribute name, and attribute type. Note that the for="node" statement defines each property as a vertex property.

  4. Define the edge properties.

    <key id="labelE" for="edge""labelE" attr.type="string"/>
    <key id="stars" for="edge""stars" attr.type="string"/>
    <key id="ratedDate" for="edge""ratedDate" attr.type="string"/>
    <key id="comment" for="edge""comment" attr.type="string"/>
    <key id="amount" for="edge""amount" attr.type="string"/>

    The property with id labelE is always defined, as each edge has a edge identifier denoted by the label. Additional edge properties are defined with an ID, attribute name, and attribute type. Note that the for="edge" statement defines each property as a edge property.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000,