You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@s2graph.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/06/12 08:21:00 UTC
[jira] [Commented] (S2GRAPH-219) Added query that includes all
vertices and associated edges for GraphVisualize.
[ https://issues.apache.org/jira/browse/S2GRAPH-219?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16509327#comment-16509327 ]
ASF GitHub Bot commented on S2GRAPH-219:
----------------------------------------
GitHub user daewon opened a pull request:
https://github.com/apache/incubator-s2graph/pull/170
[S2GRAPH-219] Added query that includes all vertices and associated edges for GraphVisualize.
# Added query that includes all vertices and associated edges for GraphVisualize.
I added a functionality a data format that includes Vertices, Edges in the GraphQL query results .
The data format is similar to [GraphSON](http://tinkerpop.apache.org/docs/current/reference/#graphson-io-format)
The data format for embedding the Graph is very similar, so it would be very useful for testing Visualize tools such as [sigma.js](http://sigmajs.org/) and graph algorithms.
## How to Include Graph Format in Data
Perform a general query as shown below.
Include "includeGraph" in the query variable below.
- Query Variable
```json
{
"includeGraph": true
}
```
- Query
```graphql
{
kakao {
user(ids: ["daewon", "shon"]) {
id
age
gender
inFriends: friends(direction: in, limit: 3) {
user {
id
}
}
}
}
}
```
As you can see in the above query, you can see that the graph has a `graph` key under the `extensions` entry with the query results, and that the data contains nodes (vertices) and edges.
```json
{
"data": {
"kakao": {
"user": [
{
"id": "daewon",
"age": 20,
"gender": "M",
"inFriends": []
},
{
"id": "shon",
"age": 19,
"gender": "F",
"inFriends": [
{
"user": {
"id": "daewon"
}
}
]
}
]
}
},
"extensions": {
"graph": {
"nodes": [
{
"id": "kakao.user.daewon",
"label": "daewon"
},
{
"id": "kakao.user.shon",
"label": "shon"
}
],
"edges": [
{
"source": "kakao.user.shon",
"target": "kakao.user.daewon",
"id": "kakao.user.shon.friends.kakao.user.daewon",
"label": "friends"
}
]
}
}
}
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/daewon/incubator-s2graph S2GRAPH-219
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-s2graph/pull/170.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #170
----
commit bb78c7d602614ede86e93b465f0eafee50ee0554
Author: daewon <da...@...>
Date: 2018-06-08T07:58:21Z
add extension for SigmaJs
commit c13a5e92d248f028fab5a110a61f9a98ea0d7993
Author: daewon <da...@...>
Date: 2018-06-12T08:04:33Z
make middleware for GraphFormatWriter
----
> Added query that includes all vertices and associated edges for GraphVisualize.
> -------------------------------------------------------------------------------
>
> Key: S2GRAPH-219
> URL: https://issues.apache.org/jira/browse/S2GRAPH-219
> Project: S2Graph
> Issue Type: New Feature
> Components: s2graphql
> Reporter: Daewon Jeong
> Assignee: Daewon Jeong
> Priority: Minor
>
> h1. Supports result format for GraphVisualize.
> The query result of S2Graph is suitable for checking connected data.
> However, such as [sigma.js|http://sigmajs.org/], the Grpah drawing tool must process the results to use it.
> Connecting all vertices and edges is a complex and tedious task.
> Therefore, supports the result format which is easy to use in Graph Tools like the [sigma.js|http://sigmajs.org/].
> [sigma.js|http://sigmajs.org/] requires the following form.
> {code:json}
> {
> "nodes": [
> {
> "id": "n0",
> "label": "A node",
> "x": 0,
> "y": 0,
> "size": 3
> },
> {
> "id": "n1",
> "label": "Another node",
> "x": 3,
> "y": 1,
> "size": 2
> },
> {
> "id": "n2",
> "label": "And a last one",
> "x": 1,
> "y": 3,
> "size": 1
> }
> ],
> "edges": [
> {
> "id": "e0",
> "source": "n0",
> "target": "n1"
> },
> {
> "id": "e1",
> "source": "n1",
> "target": "n2"
> },
> {
> "id": "e2",
> "source": "n2",
> "target": "n0"
> }
> ]
> }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)