<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) &gt; [graphTree](./brick-next-pipes.graphtree.md)

## graphTree() function

将[图遍历查询接口](http://192.168.100.162/next/developers/providers/cmdb/instance-graph-api-traverse-graph)<!-- -->返回的图数据转换为树结构数据。

 Others

**Signature:**

```typescript
export declare function graphTree(value: GraphData, query?: GraphQuery): GraphVertex[];
```

## Parameters

|  Parameter | Type | Description |
|  --- | --- | --- |
|  value | [GraphData](./brick-next-pipes.graphdata.md) | 图数据。 |
|  query | [GraphQuery](./brick-next-pipes.graphquery.md) | 图查询条件及排序等。 |

**Returns:**

[GraphVertex](./brick-next-pipes.graphvertex.md)<!-- -->\[\]

树结构数据。

## Example


```ts
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"}]}
// ]
```


