Skip to main content
edited tags
Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
edited title
Link
user64494
  • 29.1k
  • 4
  • 29
  • 56

creating Creating a histogram of the number of edges in a digraph

Source Link
Tugrul Temel
  • 6.4k
  • 3
  • 14
  • 33

creating a histogram of the number of edges in a digraph

I have the following Code which calculates the number of edges in a range theta1 and theta2. As seen from this Manipulate, one can arbitrarily choose a lower and upper bound for mm and simply see the associated digraph as well as the total number of edges in it. Basically, this is a histogram of edges, but a very disaggragted one.

Clear[mm, vLabels, selectBetween, subgraphBetween];
mm = RandomReal[0.5, {10, 10}];
vLabels = {1 -> AGR, 2 -> FIS, 3 -> CO1, 4 -> CO2, 5 -> MA1, 6 -> MA2,
7 -> EGW, 8 -> CST, 9 -> WHS, 10 -> HOT};
selectBetween[\[Theta]1_, \[Theta]2_] := 
BoolEval[\[Theta]1 <= mm <= \[Theta]2];
subgraphBetween[\[Theta]1_, \[Theta]2_] := 
AdjacencyGraph[selectBetween[\[Theta]1, \[Theta]2],
PlotLabel -> \[Theta]1 <= Subscript[m, ij] <= \[Theta]2, 
VertexSize -> 0.3, VertexLabels -> vLabels , ImagePadding -> 20, 
ImageSize -> 150];
Manipulate[
Grid[
{{"Digraph within the range for \!\(\*SubscriptBox[\(m\), \
\(ij\)]\)", 
"Total number of edges in the interval"}, {subgraphBetween[\
\[Theta]1, \[Theta]2], 
EdgeCount[subgraphBetween[\[Theta]1, \[Theta]2]]}} // Transpose
],
{{\[Theta]1, 0.00001, 
"Threshold \[Theta]1 < \!\(\*SubscriptBox[\(m\), \(ij\)]\)"}, 
0.00001, 0.5, 0.01},
{{\[Theta]2, 0.00001, 
"\!\(\*SubscriptBox[\(m\), \(ij\)]\) < Threshold \[Theta]2"}, 
0.00001, 0.5, 0.01}
]

I like to have a histogram of edges in mm in which each ban is defined by a range from theta1 to theta2. I also like to see the number of edges on top of each bar in the histogram so that the reader will immediately see how many edges exist in the relevant bar.

Thank you for your help.