Tip #1 - introduction and 'show the whole graph'

So, I will be adding a bunch of functions and other useful tips that I have found in my time using TigerGraph. Questions welcome.

So #1: How do you show the entire graph.

Here is a small function. Extra points for spotting the way I avoid using up memory. You only need to adjust the name of the graph on the definition line. Everything else will just work.

CREATE QUERY tips_show_graph() FOR GRAPH Claims { 
// WHOLE GRAPH:
//  Show it all, including attributes!
  ListAccum <EDGE> @@allE;
  G = {ANY};
	
  G2 = SELECT s FROM G:s-(:e)->:t 
	ACCUM @@allE += e
	HAVING 1==0;
	
  PRINT G, @@allE;
	
}
1 Like

Want to just show whole topology or with all attributes belongs them?

1 Like

All the attributes too.

1 Like

A quick addition to this I hit today.
Edges and vertices have a .type pseudo-string. I say it is a pseudo-string because it does have a few gotchas. Today, for example, I wanted to show my entire graph, but not see the reverse edges (as they clutter things up).

So I tried this:

CREATE QUERY showAll() FOR GRAPH MyGraph { 

  ListAccum <EDGE> @@AllE;
  
  AllV={ANY};
  
  AllV = select a from AllV:a-(:e)-:t
  ACCUM
  CASE WHEN e.type NOT LIKE "reverse%" THEN @@AllE += e END;
  
  PRINT AllV, @@AllE; 
}

Got this:
Error: 'var.Type LIKE regex' is not supported. Please spell out the types in disjunction.

(side note: a disjunction is an OR or an IN alternation).

Well I have 15 edge types, and spelling them out rather breaks the idea. But there is a workaround! We can force the .type into a real string like so. Note the use of an initialised local variable in the ACCUM clause, and the use of the CASE.:

CREATE QUERY showAll() FOR GRAPH MyGraph { 

  ListAccum <EDGE> @@AllE;
  
  AllV={ANY};
  
  AllV = select a from AllV:a-(:e)-:t
  ACCUM
    STRING getType=e.type,
    CASE WHEN getType NOT LIKE "reverse%" THEN @@AllE += e END;
  
  PRINT AllV, @@AllE; 
}

Works like a champ! Saved me some time anyway. Hopefully it will help you too.

1 Like