Can NetworkX library read RDF data in Ntriple format and build a Graph object along with attributes or node features
Asked Answered
Y

0

6

Can NetworkX library read RDF data in Ntriple format and build a Graph object along with attributes or node features. I tried the below code to convert the RDF data(.nt file) in to Graph using the rdflib,

from rdflib.extras.external_graph_libs import *
from rdflib import Graph, URIRef, Literal
import networkx as nx

graph = Graph()
graph.parse(“Airports-with-lables.nt”, format=“nt”)
nx_graph = rdflib_to_networkx_multidigraph(graph)
nx.write_graphml(nx_graph,“example_airport.graphml”)

However the generated grahml file doesn’t have attributes, because of which I am not able to proceed with StellarGraph Hinsage algorithm(https://github.com/stellargraph/stellargraph/tree/develop/demos/node-classification/hinsage) which expects the node features as one of the parameter.

Can anyone help on this please.

Yen answered 23/7, 2019 at 15:40 Comment(1)
the method does exactly what it's supposed to do, subjects and objects are the later nodes of the MultiDiGraph, predicates are used as edge keys (to identify multi-edges).Kizzykjersti

© 2022 - 2024 — McMap. All rights reserved.