Skip to the content.

Home > @easyops-cn/brick-next-pipes > graphTree

graphTree() function

图遍历查询接口返回的图数据转换为树结构数据。

Others

Signature:

export declare function graphTree(value: GraphData, query?: GraphQuery): GraphVertex[];

Parameters

Parameter Type Description
value GraphData 图数据。
query GraphQuery 图查询条件及排序等。

Returns:

GraphVertex[]

树结构数据。

Example

const data: GraphData = {
  topic_vertices: [
    {
      instanceId: "1",
      name: "A",
    },
    {
      instanceId: "2",
      name: "B",
    }
  ],
  vertices: [
    {
      instanceId: "3",
      name: "C",
    },
    {
      instanceId: "4",
      name: "D",
    }
  ],
  edges: [
    {
      out: "1",
      in: "3",
      out_name: "children",
    },
    {
      out: "2",
      in: "4",
      out_name: "children",
    }
  ]
}
graphTree(data)
// Returns:
// [
//   {instanceId: "1", name: "A", children: [{instanceId: "3", name: "C"}]},
//   {instanceId: "2", name: "B", children: [{instanceId: "4", name: "D"}]}
// ]