CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2014
    Posts
    1

    Question Build DAG from Objects

    I have this problem
    There are a collection of objects, each object has it properties and a list of objects that depens of. So I want to generate a Directly Acyclic Graph, that can model the dependency of every object. Also mutual conection doesn't exists, so object A depends object B, so object B can't depends object A, thats a rule that must follow every object, if happens then object A and object B automatically get merge in object C, so A+B=C. There is an algorithm for this situation?

  2. #2
    Join Date
    Jul 2013
    Posts
    576

    Re: Build DAG from Objects

    Quote Originally Posted by firomero View Post
    Also mutual conection doesn't exists, so object A depends object B, so object B can't depends object A, thats a rule that must follow every object, if happens then object A and object B automatically get merge in object C, so A+B=C.
    It seems you want to identify all cyclic (strongly connected) objects in a directed grapth. Have a look here,

    http://en.wikipedia.org/wiki/Strongl...cted_component

    Especially Tarjan's algorithm looks interesting.

    If you run Tarjan repeatedly and each time merge all strongly connected objects until Tarjan comes up empty, what remains must be a DAG.
    Last edited by razzle; December 18th, 2014 at 05:49 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured