# Problem

I do not understand Mathematica's Documentation for Labeled, VertexLabels, VertexRenderingFunction, etc

I want to make a Graph that has Tooltip enabled for verticies and edges, has PopupWindow enabled for the verticies, has different colors for edges of different type, different colors for specific verticies, and smaller arrows, etc.

## Example

I have a list of index pairs, e.g.

indexList = {
{1,3},{1,4},{1,5},
{4,2},{4,1},
{5,2}
};


Just for purpose of this example lets say I have a list with labels for my verticies and edges

vertexLabels = {"a","b","c","d","e"};
edgeLabels = {"e1","e2","e3","e4","e5","e6"};


## Convert index pairs to directed edges

directedEdges = Table[indexList[[i]][] \[DirectedEdge] indexList[[i]][],{i,1,Length[indexList]}];


## Apply Tooltip to directed edges

directedEdgesTooltip = Table[Tooltip[directedEdges[[i]], edgeLabels[[i]]],{i,1,Length[directedEdges]}];


But supposedily one can use Labeled

directedEdgesLabeled = Table[Labeled[directedEdges[[i]], edgeLabels[[i]],Tooltip],{i,1,Length[directedEdges]}];


Calling Graph on this works-ish Graph[directedEdgesLabeled]

But that isn't how it should work. Supposedily I should call

Graph[directedEdges,EdgeLabels -> directedEdgesLabeled]


But that doesn't work. As you'll see this goes on for Verticies too.

## Apply Tooltip to Verticies

verticiesLabeled = Table[Labeled[Range[[i]], vertexLabels[[i]],Tooltip],{i,1,Length[Range]}];


So lets try again

Graph[directedEdges, VertexLabels -> verticiesLabeled]


Oh darn... that doesn't work.

What about using Tooltip on the directedEdges? Well that works, if you only want the vertex labeled.

## Note

Nesting Labeled does not work

Labeled[Labeled[1, "a", Tooltip] \[DirectedEdge] Labeled[2, "b", Tooltip], "e1", Tooltip]


# Question

So please someone tell me how to do this. We haven't even got into adding PopupWindow (which I have tried a myraid of methods for).

• Just noting that GraphPlot is the old way of plotting graphs and has mostly been replaced by Graph since version 8.0. Sep 2, 2016 at 19:02
• @Szabolcs, I thought GraphPlot was the new way of doing so, as Head[Graph] is Graph and Head[GraphPlot] is Graphic... Sep 3, 2016 at 8:50
• Why do you think the head has any relevance to this? If you want to convert a Graph to pure Graphics, use Show. Sep 3, 2016 at 10:10
• @Szabolcs I don't... it is that Mathematica is all about standardization of langauge, which is why I though GraphPlot was brought into existance... Anyway using Graph with the graph I described above does not work, which is why I gravitated towards GraphPlot because that actually produced a graphic Sep 3, 2016 at 11:14
• Look up the correct syntax for Graph. It's not the same. Sep 3, 2016 at 11:53

# Answer to getting Labeled Edges and Verticies

1.) Do not use Labeled, use Placed. See below:

makeEdgeLabels[directedEdges_] :=
Table[directedEdges[[i]] ->
Placed[getEdgeLabel[directedEdges[[i]]], Tooltip], {i, 1,
Length[directedEdges]}]

makeVertexLabels[indexList_] := Module[
{iL = DeleteDuplicates[Flatten[indexList]]},
Return[
Table[iL[[i]] -> Placed[proteinNames[[iL[[i]]]], Tooltip], {i, 1,
Length[iL]}]
]
]

Graph[directedEdges,EdgesLabels-> makeEdgeLabels[directedEdges],VertexLabels->makeVertexLabels[directedEdges]]