Message Boards Message Boards

1
|
6699 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Can not label a directed-undirected graph

Posted 10 years ago

Here is a directed-undirected graph

(* illustration of a solution: {{1,3,4,8,9},{10,11,13,17,18},{21,23,25}} *)
Clear[vL, vC]
vL = Flatten[{{1, 3, 4, 8, 9}, {10, 11, 13, 17, 18}, {21, 23, 25}} ];
vC = Rule[#, ToString[#]] & /@ vL;

Graph[{1 <-> 3, 1 <-> 4, 1 <-> 7, 1 <-> 9, 3 <-> 4, 3 <-> 7, 3 <-> 9, 
  4 <-> 7, 4 <-> 9, 7 <-> 9, 9 \[DirectedEdge] 10, 10 <-> 11, 
  10 <-> 13, 10 <-> 17, 10 <-> 18, 11 <-> 13, 11 <-> 17, 11 <-> 18, 
  13 <-> 17, 13 <-> 18, 17 <-> 18, 18 \[DirectedEdge] 21, 21 <-> 23, 
  21 <-> 25, 23 <-> 25}, (* VertexLabels\[Rule]vC,*)
 VertexSize -> Large]

it displays the graph

dd-ud-graph

if the VertexLabels are included,

In[36]:= Graph[{1 <-> 3, 1 <-> 4, 1 <-> 7, 1 <-> 9, 3 <-> 4, 3 <-> 7, 
  3 <-> 9, 4 <-> 7, 4 <-> 9, 7 <-> 9, 9 \[DirectedEdge] 10, 10 <-> 11,
   10 <-> 13, 10 <-> 17, 10 <-> 18, 11 <-> 13, 11 <-> 17, 11 <-> 18, 
  13 <-> 17, 13 <-> 18, 17 <-> 18, 18 \[DirectedEdge] 21, 21 <-> 23, 
  21 <-> 25, 23 <-> 25}, VertexLabels -> vC, VertexSize -> Large]
(* no graph graphics *)

Out[36]= Graph[{1 <-> 3, 1 <-> 4, 1 <-> 7, 1 <-> 9, 3 <-> 4, 3 <-> 7, 
  3 <-> 9, 4 <-> 7, 4 <-> 9, 7 <-> 9, 9 \[DirectedEdge] 10, 10 <-> 11,
   10 <-> 13, 10 <-> 17, 10 <-> 18, 11 <-> 13, 11 <-> 17, 11 <-> 18, 
  13 <-> 17, 13 <-> 18, 17 <-> 18, 18 \[DirectedEdge] 21, 21 <-> 23, 
  21 <-> 25, 23 <-> 25}, 
 VertexLabels -> {1 -> "1", 3 -> "3", 4 -> "4", 8 -> "8", 9 -> "9", 
   10 -> "10", 11 -> "11", 13 -> "13", 17 -> "17", 18 -> "18", 
   21 -> "21", 23 -> "23", 25 -> "25"}, VertexSize -> Large]

no graph shows up anymore. A work-around is welcomned. Thanks in advance.


P.S.: A simple[r] example works

Graph[{1 <-> 2, 2 <-> 3, 3 <-> 1, 3 \[DirectedEdge] 4, 4 <-> 5, 
  5 <-> 6, 6 <-> 4}, 
 VertexLabels -> {1 -> "1", 2 -> "2", 3 -> "3", 4 -> "4", 5 -> "5", 
   6 -> "6"}]

simple-d-ud-g


Mathematica 10.1.0, Windows 7 64 Bit Home Premium.

POSTED BY: Udo Krause
2 Replies

Behaviour persistent under Mathematica 10.2.0, Windows 7 64 Bit Home Premium.

POSTED BY: Udo Krause

Behaviour once more persistent under Mathematica 10.4.1, Windows 10 Professional 64 Bit.

POSTED BY: Udo Krause
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract