antvis / G6VP

G6VP is an online visual analysis tool for graphs and a low-code platform for building graph applications.
https://insight.antv.antgroup.com
Apache License 2.0
797 stars 109 forks source link

[Support] Graph Rendering Exception when Querying Official Movie Dataset in Neo4j #555

Closed nylqd closed 9 months ago

nylqd commented 9 months ago

Description:

I encountered an issue while querying the official movie dataset in Neo4j using the following Cypher query: MATCH p=()-->() RETURN p LIMIT 25. The problem arises when attempting to render the results on the canvas, as the rendering process behaves unexpectedly.

Expected Behavior:

截屏2023-11-19 14 59 05

Actual Behavior

截屏2023-11-19 14 55 30

Console logs

截屏2023-11-19 15 02 13

Request for Assistance:

I would appreciate your assistance in locating and resolving the issue with the canvas rendering when querying the official movie dataset. If possible, please provide guidance on any potential solutions or workarounds.

Thank you for your support.

pomelo-nwu commented 9 months ago

@nylqd 感谢发现问题,应该是数据解析出现问题,后面我们修复下

pomelo-nwu commented 9 months ago

@nylqd you can start debugging the issue from here: https://github.com/antvis/G6VP/blob/master/packages/gi-assets-neo4j/src/services/CypherQuery.ts#L11

nylqd commented 9 months ago

processResult as follow, is there any problem?

{
    "nodes": [
        {
            "id": "1",
            "label": "Person",
            "nodeType": "Person",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Person",
                "GI_TYPE": "Person",
                "born": {
                    "low": 1964,
                    "high": 0
                },
                "name": "Keanu Reeves"
            }
        },
        {
            "id": "0",
            "label": "Movie",
            "nodeType": "Movie",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Movie",
                "GI_TYPE": "Movie",
                "tagline": "Welcome to the Real World",
                "title": "The Matrix",
                "released": {
                    "low": 1999,
                    "high": 0
                }
            }
        },
        {
            "id": "2",
            "label": "Person",
            "nodeType": "Person",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Person",
                "GI_TYPE": "Person",
                "born": {
                    "low": 1967,
                    "high": 0
                },
                "name": "Carrie-Anne Moss"
            }
        },
        {
            "id": "3",
            "label": "Person",
            "nodeType": "Person",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Person",
                "GI_TYPE": "Person",
                "born": {
                    "low": 1961,
                    "high": 0
                },
                "name": "Laurence Fishburne"
            }
        },
        {
            "id": "4",
            "label": "Person",
            "nodeType": "Person",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Person",
                "GI_TYPE": "Person",
                "born": {
                    "low": 1960,
                    "high": 0
                },
                "name": "Hugo Weaving"
            }
        },
        {
            "id": "5",
            "label": "Person",
            "nodeType": "Person",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Person",
                "GI_TYPE": "Person",
                "born": {
                    "low": 1967,
                    "high": 0
                },
                "name": "Lilly Wachowski"
            }
        },
        {
            "id": "6",
            "label": "Person",
            "nodeType": "Person",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Person",
                "GI_TYPE": "Person",
                "born": {
                    "low": 1965,
                    "high": 0
                },
                "name": "Lana Wachowski"
            }
        },
        {
            "id": "7",
            "label": "Person",
            "nodeType": "Person",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Person",
                "GI_TYPE": "Person",
                "born": {
                    "low": 1952,
                    "high": 0
                },
                "name": "Joel Silver"
            }
        },
        {
            "id": "8",
            "label": "Person",
            "nodeType": "Person",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Person",
                "GI_TYPE": "Person",
                "born": {
                    "low": 1978,
                    "high": 0
                },
                "name": "Emil Eifrem"
            }
        },
        {
            "id": "9",
            "label": "Movie",
            "nodeType": "Movie",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Movie",
                "GI_TYPE": "Movie",
                "tagline": "Free your mind",
                "title": "The Matrix Reloaded",
                "released": {
                    "low": 2003,
                    "high": 0
                }
            }
        },
        {
            "id": "10",
            "label": "Movie",
            "nodeType": "Movie",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Movie",
                "GI_TYPE": "Movie",
                "tagline": "Everything that has a beginning has an end",
                "title": "The Matrix Revolutions",
                "released": {
                    "low": 2003,
                    "high": 0
                }
            }
        },
        {
            "id": "11",
            "label": "Movie",
            "nodeType": "Movie",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Movie",
                "GI_TYPE": "Movie",
                "tagline": "Evil has its winning ways",
                "title": "The Devil's Advocate",
                "released": {
                    "low": 1997,
                    "high": 0
                }
            }
        },
        {
            "id": "12",
            "label": "Person",
            "nodeType": "Person",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Person",
                "GI_TYPE": "Person",
                "born": {
                    "low": 1975,
                    "high": 0
                },
                "name": "Charlize Theron"
            }
        },
        {
            "id": "13",
            "label": "Person",
            "nodeType": "Person",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Person",
                "GI_TYPE": "Person",
                "born": {
                    "low": 1940,
                    "high": 0
                },
                "name": "Al Pacino"
            }
        }
    ],
    "edges": [
        {
            "id": "0",
            "source": "1",
            "target": "0",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "1",
                "target": "0",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Neo"
                ]
            }
        },
        {
            "id": "1",
            "source": "2",
            "target": "0",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "2",
                "target": "0",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Trinity"
                ]
            }
        },
        {
            "id": "2",
            "source": "3",
            "target": "0",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "3",
                "target": "0",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Morpheus"
                ]
            }
        },
        {
            "id": "3",
            "source": "4",
            "target": "0",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "4",
                "target": "0",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Agent Smith"
                ]
            }
        },
        {
            "id": "4",
            "source": "5",
            "target": "0",
            "label": "DIRECTED",
            "edgeType": "DIRECTED",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "5",
                "target": "0",
                "GI_TYPE": "DIRECTED"
            }
        },
        {
            "id": "5",
            "source": "6",
            "target": "0",
            "label": "DIRECTED",
            "edgeType": "DIRECTED",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "6",
                "target": "0",
                "GI_TYPE": "DIRECTED"
            }
        },
        {
            "id": "6",
            "source": "7",
            "target": "0",
            "label": "PRODUCED",
            "edgeType": "PRODUCED",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "7",
                "target": "0",
                "GI_TYPE": "PRODUCED"
            }
        },
        {
            "id": "7",
            "source": "8",
            "target": "0",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "8",
                "target": "0",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Emil"
                ]
            }
        },
        {
            "id": "8",
            "source": "1",
            "target": "9",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "1",
                "target": "9",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Neo"
                ]
            }
        },
        {
            "id": "9",
            "source": "2",
            "target": "9",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "2",
                "target": "9",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Trinity"
                ]
            }
        },
        {
            "id": "10",
            "source": "3",
            "target": "9",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "3",
                "target": "9",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Morpheus"
                ]
            }
        },
        {
            "id": "11",
            "source": "4",
            "target": "9",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "4",
                "target": "9",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Agent Smith"
                ]
            }
        },
        {
            "id": "12",
            "source": "5",
            "target": "9",
            "label": "DIRECTED",
            "edgeType": "DIRECTED",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "5",
                "target": "9",
                "GI_TYPE": "DIRECTED"
            }
        },
        {
            "id": "13",
            "source": "6",
            "target": "9",
            "label": "DIRECTED",
            "edgeType": "DIRECTED",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "6",
                "target": "9",
                "GI_TYPE": "DIRECTED"
            }
        },
        {
            "id": "14",
            "source": "7",
            "target": "9",
            "label": "PRODUCED",
            "edgeType": "PRODUCED",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "7",
                "target": "9",
                "GI_TYPE": "PRODUCED"
            }
        },
        {
            "id": "15",
            "source": "1",
            "target": "10",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "1",
                "target": "10",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Neo"
                ]
            }
        },
        {
            "id": "16",
            "source": "2",
            "target": "10",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "2",
                "target": "10",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Trinity"
                ]
            }
        },
        {
            "id": "17",
            "source": "3",
            "target": "10",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "3",
                "target": "10",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Morpheus"
                ]
            }
        },
        {
            "id": "18",
            "source": "4",
            "target": "10",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "4",
                "target": "10",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Agent Smith"
                ]
            }
        },
        {
            "id": "19",
            "source": "5",
            "target": "10",
            "label": "DIRECTED",
            "edgeType": "DIRECTED",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "5",
                "target": "10",
                "GI_TYPE": "DIRECTED"
            }
        },
        {
            "id": "20",
            "source": "6",
            "target": "10",
            "label": "DIRECTED",
            "edgeType": "DIRECTED",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "6",
                "target": "10",
                "GI_TYPE": "DIRECTED"
            }
        },
        {
            "id": "21",
            "source": "7",
            "target": "10",
            "label": "PRODUCED",
            "edgeType": "PRODUCED",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "7",
                "target": "10",
                "GI_TYPE": "PRODUCED"
            }
        },
        {
            "id": "22",
            "source": "1",
            "target": "11",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "1",
                "target": "11",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Kevin Lomax"
                ]
            }
        },
        {
            "id": "23",
            "source": "12",
            "target": "11",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "12",
                "target": "11",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Mary Ann Lomax"
                ]
            }
        },
        {
            "id": "24",
            "source": "13",
            "target": "11",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "13",
                "target": "11",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "John Milton"
                ]
            }
        }
    ],
    "table": {
        "headers": [],
        "rows": []
    }
}
nylqd commented 9 months ago
image

another simple example here MATCH p=()-->() RETURN p LIMIT 2

{
    "nodes": [
        {
            "id": "1",
            "label": "Person",
            "nodeType": "Person",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Person",
                "GI_TYPE": "Person",
                "born": {
                    "low": 1964,
                    "high": 0
                },
                "name": "Keanu Reeves"
            }
        },
        {
            "id": "0",
            "label": "Movie",
            "nodeType": "Movie",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Movie",
                "GI_TYPE": "Movie",
                "tagline": "Welcome to the Real World",
                "title": "The Matrix",
                "released": {
                    "low": 1999,
                    "high": 0
                }
            }
        },
        {
            "id": "2",
            "label": "Person",
            "nodeType": "Person",
            "nodeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "label": "Person",
                "GI_TYPE": "Person",
                "born": {
                    "low": 1967,
                    "high": 0
                },
                "name": "Carrie-Anne Moss"
            }
        }
    ],
    "edges": [
        {
            "id": "0",
            "source": "1",
            "target": "0",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "1",
                "target": "0",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Neo"
                ]
            }
        },
        {
            "id": "1",
            "source": "2",
            "target": "0",
            "label": "ACTED_IN",
            "edgeType": "ACTED_IN",
            "edgeTypeKeyFromProperties": "GI_TYPE",
            "data": {
                "source": "2",
                "target": "0",
                "GI_TYPE": "ACTED_IN",
                "roles": [
                    "Trinity"
                ]
            }
        }
    ],
    "table": {
        "headers": [],
        "rows": []
    }
}
nylqd commented 9 months ago

@pomelo-nwu It seems like the issue stems from duplicate IDs between edges and nodes, leading to complications in the rendering process. I've considered a possible solution, specifically within the processResult method.

image

My suggestion involves making slight modifications to the IDs of edges, perhaps by adding a distinctive prefix. This adjustment aims to mitigate conflicts and enhance the uniqueness of identifiers, potentially resolving the rendering anomalies.

image image

https://github.com/antvis/G6VP/blob/4b2e4c9e6b2792227780993b3b3e84d6fdebe7a2/packages/gi-assets-neo4j/src/services/Driver.tsx#L181

https://github.com/antvis/G6VP/blob/4b2e4c9e6b2792227780993b3b3e84d6fdebe7a2/packages/gi-assets-neo4j/src/services/Driver.tsx#L239

pomelo-nwu commented 9 months ago

@nylqd Great job! Feel free to submit a pull request