 ### Graph Redis

Here is a list of all the graph related commands supported by graph-redis

## gnode

This command is used to add one, or more, nodes to a graph. graph will be created if it doesn't already exist.

gnode graph_name node [node ...]

## gnoderem

Removes a node and all its edges

gnoderem graph_name node

### Return value

Returns 1 of the node exists, 0 if it doesn't exist

## gnodeindegree

Returns the indegree of the node (number of incoming edges)

gnodeindegree graph_name node

## gnodeoutdegree

Returns the outdegree of the node (number of outcoming edges). For directed graphs, it returns the number of edges connected to the node

gnodeoutdegree graph_name node

## gedge

gnodes graph_name node1 node2

This commands adds a new edge between node1 and node2. If the edge already exists, the edge value will be updated.

### Return value

Returns the edge value

## gnodeexists

gnodeexists graph_name node

### Return value

Returns 1 if the node exists in the graph (graph_name), otherwise it returns 0

## gnodes

gnodes graph_name pattern

### Return value

Returns list of graph nodes that match the pattern string

## gedgeexists

gedgeexists graph_name node1 node2

### Return value

Returns 1 if there is an edge that exists between node1 and node2 in the graph graph_name

## gedgevalue

Returns the value of the edge between two nodes

gedgevalue graph_name node1 node2

### Return value

The value of the edge between node1 and node2

## gedges

Returns a list of all the edges and their values in the graph, ordered by the time of insertion

gedges graph_name

### Return value

A list of length (3 * edges_Count). Each 3 elements represent node 1, node 2, and the edge value

## gneighbours

Returns a list of a node neighbours

gneighbours graph_name node

## gmaxneighbour

Returns the neighbour of a node with the highest value of the edge

The return value is an array of 2 elements, the neighbour name and the value of the edge

If the node has no neighbours, the return value will be a zero

gmaxneighbour graph_name node

## gcommon

This command is used to retrieve a list of all the common neighbours between two nodes in one graph

gcommon graph_name node1 node2

### Return value

A list of the common neighbours

## gshortestpath

This command runs Dijkstra algorithm to find the shortest path from node 1 to node 2 in a graph

gshortestpath graph_name node1 node2

### Return value

A list that contains the nodes that build the path from node 1 to node 2, and the cost of that path.

## gmintree

This command calculates the minimum spanning tree using Prim's algorithm, and saves the resulting tree in another graph

gmintree graph_name graph2_name