Question: I have a DAG in a JSON format, where each node is an entry: it has a name, and two arrays. One array is for other nodes with arrows coming into it, another array for nodes that this node is directed towards (outgoing arrows).

So, for example: 

```
{ 
  'id': 'A',   
  'connected_from' : ['B','C'],  
  'connects_to' : ['D','E']
}

```

And I have a collection of these nodes, that all together form a DAG. 

I'd like to map the nodes to a struct to hold these nodes, where the id is simply a string, and I'd like the arrays to be vectors of pointers of this struct: 

```
struct node { 
    string id;  
    vector<node*> connected_from;
    vector<node*> connected_to;
}

```

How do I convert the node entries as 'id' in the arrays of the JSON to a pointer to the correct struct holding that node?

One obvious approach is to build a map of key-value pairs, where key = id, value = the pointer to the struct with that id, and do a lookup - but is there a better way?

Answer: 
no, given only the information that you've provided there isn't a better way: you need to build a map.

however, for single letter id's the map can possibly take the form of a simple array with e.g. 26 entries for the English alphabet.
I think your suggestion is fine... Map from ID to node. It's simple, intuitive and fast enough for practical purposes. Considering the data is being parsed from JSON, your storage and lookups are not going to significantly impact performance. If you're really concerned, then implement a Dictionary to replace your map.

In general terms, I always advocate the simplest, cleanest approach that gets the job done. Too many people obsess about memory or performance hits in algorithms, when the actual bottleneck in their code lies elsewhere.