Histogram using edges
Updated to return chart of loop-free part
You can use BarChart
for this (incorporating halmir's suggestions):
inOutGraph[e_] := With[{g = SimpleGraph @ Graph[Sort @ VertexList[e], e]},
BarChart[
Transpose @ Through @ {VertexInDegree, VertexOutDegree} @ g,
ChartLayout -> "Stacked"
]
]
inOutGraph[list]
or:
inOutGraph[e_] := With[{g = SimpleGraph @ Graph[Sort @ VertexList[e], e]},
BarChart[
Transpose @ Through @ {VertexInDegree, Minus @* VertexOutDegree} @ g,
ChartLayout -> "Stacked"
]
]
inOutGraph[list]
g1 = SimpleGraph @ Graph[Range[17], list];
{ind, outd} = Through[{VertexInDegree, VertexOutDegree}[g1]];
GraphComputation`GraphPropertyChart
GraphComputation`GraphPropertyChart[g1, Automatic -> {ind, outd},
ChartStyle -> {Blue, Yellow}, VertexShapeFunction -> None,
VertexSize -> .75, VertexLabels -> Placed["Name", Center],
ChartLegends -> {"VertexInDegree", "VertexOutDegree"}]
Add the options PolarGridLines->False
and PolarAxes->False
to get
PairedBarChart
PairedBarChart[Style[#, ColorData[97][1]] & /@ ind,
Style[#, ColorData[97][2]] & /@ outd, BarSpacing -> {3, 0, 0},
BarOrigin -> Top, ChartLabels -> Placed[Range[17], Axis]]
PairedHistogram
+ WeightedData
PairedHistogram[Style[WeightedData[Range@17, ind], ColorData[97][1]],
Style[WeightedData[Range@17, outd], ColorData[97][2]], 17,
BarSpacing -> 3, BarOrigin -> Top, Axes -> {False, True},
Epilog -> (Text[#, {#, 0}] & /@ Range[17])]
With ordered vertices
vl = VertexList@list;
degree = Association @@ Thread[{"In", "Out"} -> Through@{VertexInDegree, VertexOutDegree}@list];
degree = #[[Ordering[vl]]] & /@ degree;
vl = vl[[Ordering[vl]]];
BarChart[Transpose@Values@degree,
ChartLayout -> "Stacked",
ChartLabels -> {vl, None},
ChartLegends -> SwatchLegend[Automatic, {"In", "Out"}]]
Hope this helps.