@cosmograph/cosmos-tigergraph
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Connecting Cosmos with TigerGraph

Use Cosmos to visualize data from your TigerGraph graph database.

To begin, you will need to spin a TigerGraph on-prem solution. If you use a TigerGraph Cloud solution, be sure to enable CORS or use middleware.

To initialize the connection, run TigerGraphConnection with the details of the solution you just provisioned, including the host, the name of the graph, and your username and password. The final parameter of token is optional; if it is not provided, it will be generated when needed.

let conn = new TigerGraphConnection(host, graphname, username, password, token);

Running getTigerGraphData will convert data from specific vertex and edge types to Cosmos-compatible InputNode and InputLink types, and its two parameters are string arrays of vertex and edge types.

getTigerGraphData(vertex_type, edge_type)

This will return a Promise with InputNode and InputLink arrays with the vertices, edges, and attributes which can be used to create a graph.

conn.getTigerGraphData(["VertexType1", "VertexType2"], ["edge_type_1", "edge_type_2"]).then((data) => {
    const canvas = document.querySelector("canvas") as HTMLCanvasElement;
    const graph = new Graph(canvas);
    graph.setData(data.nodes, data.links);
});

In addition, users can run installed and interpreted queries and the results will be visualized. Currently, only vertices and edges returned in the form of lists or sets are supported. The syntax for the two are similar.

conn.runInterpretedQuery('interpreted_query_string').then((data) => {
    const canvas = document.querySelector("canvas") as HTMLCanvasElement;
    const graph = new Graph(canvas);
    graph.setData(data.nodes, data.links);
});
conn.runInstalledQuery('installed_query_name').then((data) => {
    const canvas = document.querySelector("canvas") as HTMLCanvasElement;
    const graph = new Graph(canvas);
    graph.setData(data.nodes, data.links);
});

Readme

Keywords

none

Package Sidebar

Install

npm i @cosmograph/cosmos-tigergraph

Weekly Downloads

4

Version

0.0.1

License

MIT

Unpacked Size

19.2 kB

Total Files

6

Last publish

Collaborators

  • rokotyan