Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Basically, your classes, objects, or what have you, are stored in a matrix (called <a href="http://en.wikipedia.org/wiki/Adjacency_matrix" rel="nofollow noreferrer">adjacency matrix</a>) that represents a <a href="http://en.wikipedia.org/wiki/Directed_graph" rel="nofollow noreferrer">directed graph</a> (with or without cycles). See the graph below and the corresponding adjacency matrix.</p> <p><img src="https://i.stack.imgur.com/EDeI1.png" alt="enter image description here"></p> <p>From this, we can calculate the reachability matrix, which describes to which nodes can one travel from the current node. For this graph, the reachability matrix is</p> <p><img src="https://i.stack.imgur.com/Knvdl.png" alt="enter image description here"></p> <p>You need an algorithm that rearranges the rows and the columns of the matrix, so that all non-zero elements are below the main diagonal. A sequence of object indexes for which this is true can be executed in the order in which they appear in the matrix, and all necessary dependencies for each object would be satisfied. If the graph is known to be acyclic, this can be achieved by <a href="http://en.wikipedia.org/wiki/Topological_sorting" rel="nofollow noreferrer">topological sorting</a>.</p> <p>When cycles appear in the directed graph, you won't be able to find an ordering for which this is true.</p> <p>Enter <a href="http://en.wikipedia.org/wiki/Dependency_Structure_Matrix" rel="nofollow noreferrer">Design/Dependency Structure Matrix</a> (DSM). A so called partitioning algorithm can be implemented to divide the objects into levels. For each of those levels, the objects can be executed in arbitrary order, and are not dependent one or another. For the graph above, nodes 3, 4 and 5 are not dependent on each other and can be executed in any order.</p> <p>A partitioning algorithm has been developed in (Warfield 1973), which is able to detect and isolate cycles in the DSM. This is similar to the topological sorting algorithm, but with usage of the reachability matrix to detect and isolate cycles.</p> <p>The algorithm briefly:</p> <blockquote> <ol> <li>Create a new partition level </li> <li>Calculate the reachability and the antecedent sets R(s) and A(s)</li> <li>For each element in the DSM, calculate the set product R(s)A(s)</li> <li>If R(s)A(s)=R(s), then add the element <code>s</code> to the current level</li> <li>Remove element <code>s</code> from the list, and all references to it from the reachability and antecedent sets of all other elements.</li> <li>Repeat from 1 if the item list is not empty.</li> </ol> </blockquote> <p>The antecedent set A(s) is the set of row indices of non-zero elements in column <code>s</code>, while the reachability set R(s) is the set of column indices of the non-zero elements of <code>s</code>.</p> <p>Finally, some pseudocode (in VB.NET, no less):</p> <pre><code>CalculateInitialAntecedentSets() CalculateInitialReachabilitySets() While UnlabelledItems &gt; 0 Sequence.AddNewPartitionLevel() For Each s In ReachabilityMatrix If NoDependencies(s) and AlreadyConsidered(s) Then AddToLevel(CurrentLevel, s) End If Next RemoveDependencies(ReachabilitySets, Sequence.Level(CurrentLevel)) RemoveDependencies(AntecedentSets, Sequence.Level(CurrentLevel)) UpdateConsideredList(Sequence.Level(CurrentLevel)) Unlabelled = Unlabelled - Sequence.Level(CurrentLevel).Count CurrentLevel = CurrentLevel + 1 End While </code></pre> <p>(This was the topic of my Master thesis some years ago)</p> <hr> <p>Warfield, John N. (1973), `Binary matrices in system modelling', IEEE Transactions on Systems, Man, and Cybernetics SMC-3(5), 441--449.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload