Creating Graphs

Question: A graph is a data structure that consists of vertices (nodes) and edges connecting the nodes. Graphs are great for representing relationships between two nodes, those of which are either directly or indirectly related. Graphs can be represented as either adjacency matrices or adjacency lists. For our implementations, we will use adjacency lists because we can then refer to the node values directly. We can represent adjacency lists in q using dictionaries, with the keys being the distinct nodes and the values being the adjacent nodes for each key. If there are no adjacent nodes, then the value should be an empty list. Given the below graph, represent it in q as an adjacency list.

More Information:

https://en.wikipedia.org/wiki/Adjacency_list

Example

                                
                                // represent this graph in q as a dictionary
a -> b
a -> c
b -> d
                                
                            

Solution

Tags:
dictionaries
Searchable Tags
algorithms api architecture csv data structures dictionaries disk feedhandler finance functions ingestion ipc iterators machine learning math multithreading optimizations realtime sql statistics streaming strings tables temporal websockets

Email sent!

Email not sent