{"id":17117726,"url":"https://github.com/anderspitman/graphml-js","last_synced_at":"2025-09-11T16:42:25.358Z","repository":{"id":57253302,"uuid":"69613161","full_name":"anderspitman/graphml-js","owner":"anderspitman","description":"GraphML parser for javascript","archived":false,"fork":false,"pushed_at":"2017-10-18T01:06:12.000Z","size":34,"stargazers_count":14,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T19:05:33.579Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anderspitman.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-29T22:33:17.000Z","updated_at":"2024-12-31T00:09:39.000Z","dependencies_parsed_at":"2022-08-31T22:11:51.537Z","dependency_job_id":null,"html_url":"https://github.com/anderspitman/graphml-js","commit_stats":null,"previous_names":["anderspitman/graphml.js"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anderspitman%2Fgraphml-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anderspitman%2Fgraphml-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anderspitman%2Fgraphml-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anderspitman%2Fgraphml-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anderspitman","download_url":"https://codeload.github.com/anderspitman/graphml-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665157,"owners_count":21142118,"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":[],"created_at":"2024-10-14T17:52:34.638Z","updated_at":"2025-04-13T04:35:17.646Z","avatar_url":"https://github.com/anderspitman.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Intro\n\n`graphml-js` is a simple [GraphML](http://graphml.graphdrawing.org/) parser written in TypeScript, for use in\nJavaScript projects. It is far from feature complete, and currently only includes the\nminimum functionality I need for a project I'm working on. However, it should be\neasy to add features in the future as needed by me or others.\n\n# Example Usage\n\n`graphml-js` takes in a GraphML file, and returns a `Graph` object, which contains\n`nodes` and `edges` properties, which are both arrays of `Node` and `Edge` objects,\nrespectively.\n\nThe following example is included in the examples directory.\n\nGiven the following graph taken from the [GraphML Primer](http://graphml.graphdrawing.org/primer/graphml-primer.html):\n\n`primer.graphml`:\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cgraphml xmlns=\"http://graphml.graphdrawing.org/xmlns\"  \n      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n      xsi:schemaLocation=\"http://graphml.graphdrawing.org/xmlns \n        http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd\"\u003e\n  \u003ckey id=\"d0\" for=\"node\" attr.name=\"color\" attr.type=\"string\"\u003e\n    \u003cdefault\u003eyellow\u003c/default\u003e\n  \u003c/key\u003e\n  \u003ckey id=\"d1\" for=\"edge\" attr.name=\"weight\" attr.type=\"double\"/\u003e\n  \u003cgraph id=\"G\" edgedefault=\"undirected\"\u003e\n    \u003cnode id=\"n0\"\u003e\n      \u003cdata key=\"d0\"\u003egreen\u003c/data\u003e\n    \u003c/node\u003e\n    \u003cnode id=\"n1\"/\u003e\n    \u003cnode id=\"n2\"\u003e\n      \u003cdata key=\"d0\"\u003eblue\u003c/data\u003e\n    \u003c/node\u003e\n    \u003cnode id=\"n3\"\u003e\n      \u003cdata key=\"d0\"\u003ered\u003c/data\u003e\n    \u003c/node\u003e\n    \u003cnode id=\"n4\"/\u003e\n    \u003cnode id=\"n5\"\u003e\n      \u003cdata key=\"d0\"\u003eturquoise\u003c/data\u003e\n    \u003c/node\u003e\n    \u003cedge id=\"e0\" source=\"n0\" target=\"n2\"\u003e\n      \u003cdata key=\"d1\"\u003e1.0\u003c/data\u003e\n    \u003c/edge\u003e\n    \u003cedge id=\"e1\" source=\"n0\" target=\"n1\"\u003e\n      \u003cdata key=\"d1\"\u003e1.0\u003c/data\u003e\n    \u003c/edge\u003e\n    \u003cedge id=\"e2\" source=\"n1\" target=\"n3\"\u003e\n      \u003cdata key=\"d1\"\u003e2.0\u003c/data\u003e\n    \u003c/edge\u003e\n    \u003cedge id=\"e3\" source=\"n3\" target=\"n2\"/\u003e\n    \u003cedge id=\"e4\" source=\"n2\" target=\"n4\"/\u003e\n    \u003cedge id=\"e5\" source=\"n3\" target=\"n5\"/\u003e\n    \u003cedge id=\"e6\" source=\"n5\" target=\"n4\"\u003e\n      \u003cdata key=\"d1\"\u003e1.1\u003c/data\u003e\n    \u003c/edge\u003e\n  \u003c/graph\u003e\n\u003c/graphml\u003e\n```\n\nAnd the following node code:\n\n`simple_example.js`:\n```javascript\nvar graphml = require('graphml-js');\nvar fs = require('fs');\n\nvar graphmlText = fs.readFileSync('primer.graphml');\nvar parser = new graphml.GraphMLParser();\n\nparser.parse(graphmlText, function(err, graphs) {\n    console.log(graphs[0]);\n});\n```\n\nThe output is:\n\n```\nGraph {\n  nodes: \n   [ Node { _id: 'n0', _attributes: [Object] },\n     Node { _id: 'n1', _attributes: {} },\n     Node { _id: 'n2', _attributes: [Object] },\n     Node { _id: 'n3', _attributes: [Object] },\n     Node { _id: 'n4', _attributes: {} },\n     Node { _id: 'n5', _attributes: [Object] } ],\n  edges: \n   [ Edge { _id: 'e0', _attributes: [Object], _source: 'n0', _target: 'n2' },\n     Edge { _id: 'e1', _attributes: [Object], _source: 'n0', _target: 'n1' },\n     Edge { _id: 'e2', _attributes: [Object], _source: 'n1', _target: 'n3' },\n     Edge { _id: 'e3', _attributes: {}, _source: 'n3', _target: 'n2' },\n     Edge { _id: 'e4', _attributes: {}, _source: 'n2', _target: 'n4' },\n     Edge { _id: 'e5', _attributes: {}, _source: 'n3', _target: 'n5' },\n     Edge { _id: 'e6', _attributes: [Object], _source: 'n5', _target: 'n4' } ] }\n```\n\n# Contribution\n\n## Build from source\nThe output directory is `dist`.\n\n```bash\n$ npm install\n$ gulp\n```\n\n## Run tests\n\n```bash\n$ gulp test\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanderspitman%2Fgraphml-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanderspitman%2Fgraphml-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanderspitman%2Fgraphml-js/lists"}