0
$\begingroup$

Does anyone know how can I differentiate vertex labels that are InDegrees vs. OutDegrees? For example, if the graph shows 1 -> 2, or all "names" from column 1 to column 2, how can I have all those in column one appear in a particular color or font, differentiated from those in column 2?

Thanks!

$\endgroup$
2
  • 3
    $\begingroup$ It is not at all clear to me what you are asking. Please add the relevant context, and use a small code example to illustrate what you are doing. $\endgroup$
    – Szabolcs
    Jul 18 at 13:47
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bbgodfrey
    Jul 18 at 15:43
1
$\begingroup$
Clear["Global`*"]

SeedRandom[1234];

n = 5;

in = RandomInteger[{1, 10}, n]

(* {1, 7, 10, 7, 1} *)

out = RandomInteger[{1, 10}, n]

(* {8, 1, 1, 9, 5} *)

Distinguish shapes and labels between in, out, and "both"

shapes = Sort[Join[Thread[in -> "Circle"] // Union,
     Thread[out -> "Square"] // Union]] /. {s___, n_ -> _, n_ -> _, 
     e___} :> {s, n -> "Star", e};

labels = Sort[Join[((# -> Style[#, Blue]) & /@ in) // Union,
     ((# -> Style[#, Orange, Italic]) & /@ out) // Union]] /. {s___, n_ -> _, 
     n_ -> _, e___} :> {s, n -> Style[n, Red, Bold], e};

Graph[
 Thread[DirectedEdge[in, out]],
 VertexLabels -> labels,
 VertexShapeFunction -> shapes,
 BaseStyle -> Medium]

enter image description here

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.