Now a day we are overwhelmed by huge and huge amounts of
data. We can store this data in the form of attributes.
How to declare
attributes?
<attribute> element is used to define an attribute.
Attributes are grouped under <attributes> element.
Every attribute has an id associated with it.
The XML-attribute class apply nested attributes on nodes
(node value) or edges (edge value).
You can also specify the default value to an attribute.
Below statements
define attributes that are applicable to a node.
<attributes
class="node">
<attribute id="0"
title="cityName" type="string" />
<attribute id="1"
title="pinCode" type="string" />
<attribute id="2"
title="website" type="anyURI" />
</attributes>
Below statements
define attributes that are applicable to an edge.
<attributes
class="edge">
<attribute id="0"
title="roadWayTravelTimeInHours" type="float" />
<attribute id="0"
title="airWayDistance" type="float">
<default>10.0</default>
</attribute>
</attributes>
How to define attributes?
By using <attvalue> element, you can define the
value of an attribute. All attribute values specific to a node (or) edge are
grouped under <attvalues> element.
Below statement
define attributes to the node 0
<node
id="0" label="A">
<attvalues>
<attvalue
for="0" value="New York"/>
<attvalue
for="1" value="NYC"/>
<attvalue
for="2" value="https://www.ny.gov/"/>
</attvalues>
</node>
Below statement
define attributes to the edge 0
<edge
id="0" source="0" target="1"
weight="2.1" label="Path from A to B"
type="directed">
<attvalues>
<attvalue
for="0" value="10.5"/>
<attvalue
for="1" value="1.2"/>
<attvalue
for="2" value="http://www.ca.gov/"/>
</attvalues>
</edge>
If you do not specify any value to an attribute, then it
takes the default value. If no default value is set for the attribute and you
omit the value for that attribute results in an error.
HelloWorld.gexf
<?xml version="1.0" encoding="UTF-8"?> <gexf xmlns="http://www.gexf.net/1.2draft" version="1.2"> <meta lastmodifieddate="2018-04-05"> <creator>Hari Krishna</creator> <description>Simple graph with two nodes</description> <keywords>basic, example</keywords> </meta> <graph> <attributes class="node"> <attribute id="0" title="cityName" type="string" /> <attribute id="1" title="pinCode" type="string" /> <attribute id="2" title="website" type="string" /> </attributes> <attributes class="edge"> <attribute id="0" title="roadWayTravelTimeInHours" type="float" /> <attribute id="0" title="airWayDistance" type="float"> <default>10.0</default> </attribute> </attributes> <!-- Define nodes here --> <nodes> <node id="0" label="A"> <attvalues> <attvalue for="0" value="New York"/> <attvalue for="1" value="NYC"/> <attvalue for="2" value="https://www.ny.gov/"/> </attvalues> </node> <node id="1" label="B"> <attvalues> <attvalue for="0" value="California"/> <attvalue for="1" value="CFN"/> <attvalue for="2" value="http://www.ca.gov/"/> </attvalues> </node> </nodes> <!-- Define edges here --> <edges> <edge id="0" source="0" target="1" weight="2.1" label="Path from A to B" type="directed"> <attvalues> <attvalue for="0" value="10.5"/> <attvalue for="1" value="1.2"/> <attvalue for="2" value="http://www.ca.gov/"/> </attvalues> </edge> </edges> </graph> </gexf>
Load above file into Gephi, you can able to see all the
attributes in ‘Data Laboratory’ view.
No comments:
Post a Comment