Given a matrix mat
:
mat = {{1, 5, 2, 6}, {4, 3, 4, 1}, {0, 1, 4, 0}, {2, 1, 3, 4}};
I want to apply the following conditions to generate various directed graphs.
- Denote columns by A, B, C, D
- Choose a column, say A (1st column), and find the binary relations between A and those cells with a number higher than 25% (threshold) of the respective column total. For example, for column A, BA and DA will be selected as the ratios (4/7 and 2/7) will be higher than 25%, respectively.
- Then choose column B because we obtained BA at step 2 and repeat the same procedure at step 2 to find those relations above 25% of the total of column B; next do the same operation for the second relation obtained in step 2, which is DA.
- Next, choose column C and follow the same operations in step 2 end so on...
- Generate a directed graph of all the significant relations obtained from the matrix
mat
.
After completing the visits to all of the columns, then apply the same steps
(1-4 above) to the transpose of the matrix mat
to generate another directed graph of the resulting relations.
I want to generate:
- two directed graphs: one for column-wise operation (
subgraph1
) and another for row-wise operation (subgraph2
) and - another directed graph combining the two directed graphs in (1) with different colors to differentiate the column-wise and row-wise graphs.
I like to produce these directed graphs using a function f[mat,th,column#]
for automated generation of the directed graphs using mat
by choosing a specific column (for example, A as column#) and a given threshold th
, and another function g[subgraph1, subgraph2, column#]
to combine the individual graphs.
UPDATE Below, I update the question with an example explaining the steps for the code development.
Starting node A:
Starting node B:
Staring node C:
Starting node D: