Update: Two methods to get the vertex labels of a Graph
object:
PropertyValue
: PropertyValue[{grph, #}, VertexLabels] & /@ VertexList[grph]
Options
: VertexLabels /. Options[grph]
gives the rules mapping vertex names to vertex labels.
Example:
argGraph = Import["http://www.arg.dundee.ac.uk/AIFdb/dot/4"];
PropertyValue[{argGraph, #}, VertexLabels] & /@ VertexList[argGraph]
(* {"The object is red.", "The object looks red.",
"Things which look red are normally red.",
"The object is illuminated by a red light.",
"RA", "CA"} *)
VertexLabels /. Options[argGraph]
(* {"239" -> "CA", "237" -> "The object is illuminated by a red light.",
"236" -> "Things which look red are normally red.",
"235" -> "The object looks red.", "234" -> "The object is red.",
"238" -> "RA"} *)
Using Graph
Graph[EdgeList[argGraph],
VertexLabels -> (MapAt[Placed[Framed[Style[#], FrameStyle -> None,
Background -> Directive[Opacity[.8], LightBlue]],
{1/2, 1/2}] &, #, {2}] & /@ (VertexLabels /. Options[argGraph])),
VertexStyle -> Directive[EdgeForm[None], White],
GraphLayout -> "RadialEmbedding",
ImagePadding -> 80, ImageSize -> 500]
Using GraphPlot
GraphPlot[EdgeList[argGraph] /. (VertexLabels /. Options[argGraph]) /.
DirectedEdge -> Rule, VertexLabeling -> True,
VertexRenderingFunction -> (Text[#2, #1, Background -> LightBlue] &),
ImageSize -> 500, Method -> "SpringEmbedding", DirectedEdges -> True]
Original post: Constructing new graphs by replacing vertices with vertex labels:
rplcmntRule = VertexLabels /. Options[argGraph]
newVertices = VertexList[argGraph] /. rplcmntRule;
newEdges = EdgeList[argGraph] /. rplcmntRule
(* {"RA" \[DirectedEdge] "The object is red.",
"The object looks red." \[DirectedEdge] "RA",
"Things which look red are normally red." \[DirectedEdge] "RA",
"CA" \[DirectedEdge] "RA",
"The object is illuminated by a red light." \[DirectedEdge] "CA"} *)
Graph[newEdges, VertexLabels -> Placed["Name", {1/2, 1/2}],
VertexShapeFunction -> "RoundedRectangle",
VertexSize -> {"Scaled", .1}]
A more "readable" version:
Graph[newEdges, VertexLabels -> Placed["Name", {1/2, 1/2}],
VertexStyle -> Directive[EdgeForm[None], White],
VertexSize -> {"Scaled", .1},
ImagePadding -> 70, GraphLayout -> "RadialEmbedding"]