Skip to content

Graphology JSON import fails with invalid nodes. Expecting an array #339

Description

@kiki286
  • Gephi Lite version : 1.0.2
  • Operating system: Windows 11
  • Web browser: Edge 152.0.4191.66
    Gephi Lite v1.0.2 rejects a minimal valid Graphology JSON file during Workspace > Open.

Reproduction:

{
  "attributes": { "name": "Test" },
  "nodes": [
    { "key": "a" },
    { "key": "b" }
  ],
  "edges": [
    {
      "key": "a-b",
      "source": "a",
      "target": "b",
      "attributes": { "weight": 1 }
    }
  ]
}

Actual result:

Graph.import: invalid nodes. Expecting an array

The same error occurs with the canonical Graphology JSON structure and without graph options.

Suspected cause: gephiLiteParse() uses a JSON reviver that converts the root object into a Graphology instance when it sees nodes and edges. The importer then checks jsonContent.nodes && jsonContent.edges and calls Graph.from(jsonContent) again. At that point nodes is a method rather than the serialized nodes array.

Expected result: the JSON should be passed to Graph.from() before, or instead of, the reviver converting it into a Graphology instance.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions