{"id":25205203,"url":"https://github.com/sparna-git/rdf2gephi","last_synced_at":"2025-05-13T01:23:09.977Z","repository":{"id":121194136,"uuid":"127009250","full_name":"sparna-git/rdf2gephi","owner":"sparna-git","description":"A converter from RDF knowledge graph to Gephi project files","archived":false,"fork":false,"pushed_at":"2025-02-13T19:51:25.000Z","size":55439,"stargazers_count":24,"open_issues_count":6,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-08T00:14:36.349Z","etag":null,"topics":["data-visualization","gephi","graph","knowledge-graph","rdf","sparql"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sparna-git.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-27T15:36:51.000Z","updated_at":"2025-04-22T08:54:45.000Z","dependencies_parsed_at":"2025-01-12T23:31:15.556Z","dependency_job_id":null,"html_url":"https://github.com/sparna-git/rdf2gephi","commit_stats":null,"previous_names":["sparna-git/rdf2gephi"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparna-git%2Frdf2gephi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparna-git%2Frdf2gephi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparna-git%2Frdf2gephi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sparna-git%2Frdf2gephi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sparna-git","download_url":"https://codeload.github.com/sparna-git/rdf2gephi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253851702,"owners_count":21973788,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-visualization","gephi","graph","knowledge-graph","rdf","sparql"],"created_at":"2025-02-10T09:19:21.455Z","updated_at":"2025-05-13T01:23:09.949Z","avatar_url":"https://github.com/sparna-git.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RDF-to-Gephi\n\nConverts RDF knowledge graphs to a [Gephi](https://gephi.org/) GEXF file that can be opened in Gephi. GEXF stands for [Graph Exchange XML Format](https://gexf.net/).\nSupports single RDF file, multiple files in a folder, or remote SPARQL endpoint URL. Can work either in a _\"direct and simple conversion\"_ mode, turning triples into edges, or using a set of SPARQL queries to define exactly the scope and structure of the nodes and edges that should appear in the Gexf file.\n\nSupports attributes on nodes and edges, and supports dynamic graphs generations, with a start and end date on each node and edge.\n\n## How to run\n\n1. Make sure you have Java installed\n2. Download the application from the [release section](https://github.com/sparna-git/rdf2gexf/releases)\n3. Have some RDF data at hand (one or more RDF file, or a SPARQL service you can query)\n4. Open a command-line in the directory you downloaded the app, and run `java -jar rdf2gexf-x.y-onejar.jar --help` to list the available commands and options\n5. Run a conversion command, typically the following:\n\n```sh\njava -jar rdf2gephi-1.0-onejar.jar sparql \\\n--input http://my.sparql.endpoint \\\n--edges queries/edges.rq \\\n--attributes queries/attributes.rq \\\n--labels queries/labels.rq \\\n--output output.gexf\n```\n\n6. Download and run [Gephi](https://gephi.org/)\n7. In Gephi, open the generated gexf file, and start applying layouts and colors to your graph to make it beautiful and tell your story\n\n\n## Available commands and options\n\n### direct convertion (discouraged)\n\nConverts RDF data to GEXF format directly. All literals are  considered as attributes, and all triples as edges, except `rdf:type`. `rdfs:label` is used as label.\n\nThe full options of the command are:\n\n```\n    direct      Converts RDF data to GEXF format directly. All literals are \n            considered as attributes, and all triples as edges, except \n            rdf:type. rdfsl:label is used as label.\n      Usage: direct [options]\n        Options:\n          -e, --endDateProperty\n            URI of the property in the knowledge graph holding the end date of \n            entities \n        * -i, --input\n            Path to RDF input file, or directory containing RDF files, or URL \n            of a SPARQL endpoint.\n        * -o, --output\n            Path to GEXF output file\n          -s, --startDateProperty\n            URI of the property in the knowledge graph holding the start date \n            of entities\n          -w, --weight\n            Path to a properties file associating properties to weights\n\n```\n\n### SPARQL-based conversion (preferred)\n\nThe `sparql` commands takes a set of SPARQL queries to build the structure of the Gephi graph. The command synopsis is the following:\n\n```\njava -jar rdf2gephi-1.0-onejar.jar sparql \\\n--input \u003cfile or directory or url of SPARQL endpoint\u003e \\\n--edges \u003cSPARQL query file to create edges\u003e \\\n--attributes \u003cSPARQL query file to create attributes\u003e \\\n--labels \u003cSPARQL query file to create label\u003e \\\n--output \u003coutput gexf file\u003e\n```\n\nThe full options of the command are:\n\n```\n    sparql      Converts RDF data to GEXF format using SPARQL queries.\n      Usage: sparql [options]\n        Options:\n          -a, --attributes\n            Path to the file containing the SPARQL query to retrieve \n            attributes, e.g. 'sparql/attribute.rq'. The query MUST return 3 \n            columns: the first one is the subject, the second one is the \n            attribute URI, the third one is the attribute value (a literal or \n            a URI).\n          -d, --dates\n            Path to the file containing the SPARQL query to retrieve date \n            ranges, e.g. 'sparql/dates.rq'\n          -e, --edges\n            Path to the file containing the SPARQL query to retrieve edges, \n            e.g. 'sparql/edges.rq'. The query MUST return the following \n            variables: ?subject, ?edge, ?object\n        * -i, --input\n            Path to RDF input file(s), or directory containing RDF files, or \n            URL of a SPARQL endpoint.\n          -l, --labels\n            Path to the file containing the SPARQL query to retrieve labels, \n            e.g. 'sparql/labels.rq'. The query MUST return the following \n            variables: ?subject, ?label\n        * -o, --output\n            Path to GEXF output file\n          -p, --parents\n            Deprecated. Path to the file containing the SPARQL query to \n            retrieve parents relationship, e.g. 'sparql/parents.rq'\n```\n\nAll queries are optional, and default queries are used if not provided. See below.\n\n*/!\\ Attention :* the provided queries MUST follow the following rules\n\n#### --edges / -e query\n\nThis query defines the graph structure. \nThe edges query MUST return the 3 variables: `?subject`, `?edge`, `?object`. _Optionaly_, the query CAN also result the variables `?start` and `?end` which will be interpreted as the dates of the edge in the gexf graph.\n\nAn example of such query is:\n\n```sparql\nPREFIX cdm: \u003chttp://publications.europa.eu/ontology/cdm#\u003e\nPREFIX xsd: \u003chttp://www.w3.org/2001/XMLSchema#\u003e\nSELECT ?subject ?edge ?object\nWHERE {\n    ?subject a cdm:resource_legal .\n    ?subject cdm:resource_legal_in-force true .\n    ?subject cdm:resource_legal_based_on_resource_legal ?object .\n    BIND(cdm:resource_legal_based_on_resource_legal as ?edge)\n}\n```\n\nIf not provided, the following query is used:\n\n```sparql\n# Default edges query\n# Selects all the triples in the graph\nSELECT ?subject ?edge ?object\nWHERE {\n\t?subject ?edge ?object .\n}\n```\n\n#### --labels / -l query\n\nThis query returns the labels of each node in the graph. Typically from an `rdfs:label`, `skos:prefLabel`, or anything.\nThe labels query MUST use the `?subject` variable to hold the node in the graph, and MUST return the 2 variables `?subject` and `?label`.\n\nAn example of such query is:\n\n```sparql\nPREFIX cdm: \u003chttp://publications.europa.eu/ontology/cdm#\u003e\nPREFIX xsd: \u003chttp://www.w3.org/2001/XMLSchema#\u003e\nSELECT ?subject ?label\nWHERE {\n    ?subject cdm:resource_legal_eli ?eli .\n    BIND(STRAFTER(STR(?eli), \"http://data.europa.eu/\") AS ?label)\n}\n```\n\nThis query is optional. If not provided, the following query is used:\n\n```sparql\n# Default labels query\n# Selects the first present : foaf:name, rdfs:label in english or without language, skos:prefLabel in english or without language\nPREFIX skos: \u003chttp://www.w3.org/2004/02/skos/core#\u003e\nPREFIX org: \u003chttp://www.w3.org/ns/org#\u003e\nPREFIX foaf: \u003chttp://xmlns.com/foaf/0.1/\u003e\nPREFIX epvoc: \u003chttps://data.europarl.europa.eu/def/epvoc#\u003e\nSELECT ?subject ?label\nWHERE {\n\tOPTIONAL { ?subject foaf:name ?foafName }\n\tOPTIONAL { ?subject skos:prefLabel ?prefLabel . FILTER(lang(?prefLabel) = \"en\" || lang(?prefLabel) = \"\") }\n\tOPTIONAL { ?subject rdfs:label ?rdfsLabel . FILTER(lang(?rdfsLabel) = \"en\" || lang(?rdfsLabel) = \"\") }\n\t\n\tBIND(COALESCE(?foafName, ?prefLabel, ?rdfsLabel) AS ?label)\n}\n```\n\n#### --attributes / -a query\n\nThis query returns the attributes of each node in the graph. Typically the value of `rdf:type`, and other attributes.\nThe attributes query MUST use the `?subject` variable to hold the node in the graph, and MUST return 3 variables : `?subject`, `?attribute` as the attribute type, and `?value` as the attribute value (a URI or a literal).\n\nAn example of such query is:\n\n```sparql\nPREFIX cdm: \u003chttp://publications.europa.eu/ontology/cdm#\u003e\n\nSELECT ?subject ?attribute ?value\nWHERE {\n    ?subject cdm:work_has_resource-type ?value .\n\tBIND(cdm:work_has_resource-type AS ?attribute)\n}\n```\n\nThis query is optional. If not provided, the following query is used:\n\n```sparql\n# Default attributes query\n# Selects the rdf:type value and any other property pointing to a skos:Concept\nPREFIX skos: \u003chttp://www.w3.org/2004/02/skos/core#\u003e\nPREFIX rdf: \u003chttp://www.w3.org/1999/02/22-rdf-syntax-ns#\u003e\nSELECT ?subject ?attribute ?value\nWHERE {\n\t# The rdf:type is always an attribute\n\t{ \n\t\t?subject a ?value .\n\t\tBIND(rdf:type AS ?attribute)\n\t}\n\t# Everything that is a skos:Concept is an attribute by default\n\tUNION\n\t{\n\t\t?subject ?attribute ?concept .\n\t\t?concept a skos:Concept .\n\t}\n}\t\n```\n\n\n#### --dates /-d query\n\nThis query returns the start and end date that will be associated to each node in the graph. For edges, the start and end date can be provided in the `--edges` query.\nThe dates query MUST use the `?subject` variable to hold the node in the graph, and MUST return a `?start` and `?end` variables. Only `?start` or `?end` can be returned, in which case the corresponding node will not have a start or end date associated.\n\nAn example of such query is:\n\n```sparql\nPREFIX rico: \u003chttps://www.ica.org/standards/RiC/ontology#\u003e\nPREFIX rdfs: \u003chttp://www.w3.org/2000/01/rdf-schema#\u003e\nPREFIX xsd: \u003chttp://www.w3.org/2001/XMLSchema#\u003e\nSELECT ?subject ?start ?end\nWHERE {\n    ?subject a ?type .\n    OPTIONAL { ?subject rico:beginningDate ?start . }\n    OPTIONAL { ?subject rico:endDate ?end . }\n}\n```\n\nThis query is optional. If not provided, no start and end date will be associated to the nodes.\n\n#### --parents /-p query\n\n**This is discouraged** since Gephi does not support hierarchical graphs anymore. But this could be useful for other tools, or with older versions of Gephi.\nThe parents query MUST use the `?subject` variable to hold the node in the graph, and MUST return a `?parent` variable that will hold the parent of that node in the graph.\nThis query is optional. If not provided, no default query is used and nodes will not have a parent in the graph.\n\n\n## Exemple queries\n\nLook under the [src/test/resources](https://github.com/sparna-git/rdf2gephi/tree/master/src/test/resources) for sets of example queries on various use-cases.\n\n\n## Support for dynamic graphs\n\nrdf2gephi supports the creation of dynamic graphs where we can see the evolution of the graph over time. For this:\n  1. To associate dates to edges : In the `--edges` query, return a `?start` and `?end` variables\n  2. To associate dates to nodes : provide a `--dates` query\n\n## Typical actions in Gephi to view your RDF graph\n\n1. Apply a layout algorithm : Use \"Force Atlas 2\".\n2. Give colors to nodes based on the type attribute : Appearance \u003e Nodes \u003e Partition \u003e Choose an attribute\n3. Size the nodes based on (incoming or outgoing) degree : Appearance \u003e Size icon \u003e Ranking \u003e Degree\n4. Print labels only of biggest nodes : Filter \u003e Topology \u003e Degree Range \u003e drag and drop to Queries below \u003e set the parameters. Then click on filter. Then click on icon above \"hide node/edges labels if not in filtered graph\" \n5. Click on \"Show node labels\" button\n6. You could also apply a clustering algorithm : go to Statistics \u003e Community detection \u003e Modularity. Then apply node color following the modularity attribute.\n7. Go in \"Preview\" tab, regenerate the preview, export as SVG/PNG/PDF\n\nThis is illustrated in the screencast below:\n\n[![](docs/gallery/youtube-video.png)](https://youtu.be/A_YbxNapaBY)\n\n## Gallery\n\nEU in-force legislation from Cellar SPARQL endpoint. Links shows the \"based_on\" links (acts legally based on another act). ELI identifiers of acts that are most often used as basis are shown\n\n![](docs/gallery/cellar.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparna-git%2Frdf2gephi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsparna-git%2Frdf2gephi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsparna-git%2Frdf2gephi/lists"}