Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8329877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:56:26+00:00 2026-06-09T01:56:26+00:00

I have a DAG in a JSON format, where each node is an entry:

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T01:56:28+00:00Added an answer on June 9, 2026 at 1:56 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose we have a DAG with one source. I would like to find nodes
Given a DAG, in which each node belongs to a category, how can this
I have a large (100,000+ nodes) Directed Acyclic Graph (DAG) and would like to
Given a DAG with |V| = n and has s sources we have to
I have a DAG. I have this operation to add a edge between two
I have to write an algorithm that find the path in DAG with single
Have deployed numerous report parts which reference the same view however one of them
i have the following array: [addToCart]=> array(3) { [1]=> array(5) { [aantal]=> int(1) [film_id]=>
I have a session that looks like this: array(3) { [counter]=> int(0) [currentItem]=> string(1)
I have been looking for C# examples to transform a DAG into a Tree.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.