# StandardForm on Graph edges

The Graph command displays edge labels in TraditionalForm. I instead want to use StandardForm.

I tried

EdgeLabelStyle -> Directive[StandardForm, Background -> White], but of course it does not work.

So how to do it, acting on EdgeLabelStyle?

Edit: Comment to @Sjoerd examples Your Binomial example is somewhat misleading, since Binomial has an intrinsic TraditionalForm version. What we are seeing in the graph is a sort of hybrid of Standardform (for n and k) and TraditionalForm for the parenthesis (I think). This is the proof:

As you see, even though I used braces in the notation, I still get the parenthesis in the graph (from the internal TraditionalForm), but the n, k are indeed in StandardForm.

This shows that the "StandardForm" in EdgelabelStyle does something, but it is not enough. Perhaps it is possible to play with BaseStyle?

The same thing happens if you use MakeBoxes (without ToString).

-

The style names should be between quotes (this is stated in the Style doc page, under the 'More Information' section)

edges = {1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1};
GraphicsRow[{
Graph[edges, EdgeLabels -> Exp[I x/10],
EdgeLabelStyle -> Directive["StandardForm", Red, 30],
Graph[edges, EdgeLabels -> Exp[I x/10],
}]


EDIT

Based on your comments I tried to work with Notation and MakeBoxes.

Notation doesn't seem to cause problems:

MakeBoxes seem to work if you use ToString:

gplus /: MakeBoxes[gplus[x_, y_, n_], StandardForm] :=
RowBox[{MakeBoxes[x, StandardForm],
SubscriptBox["\[CirclePlus]", MakeBoxes[n, StandardForm]],
MakeBoxes[y, StandardForm]}]

edges = {1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1};
GraphicsRow[{
Graph[edges,
EdgeLabels -> ToString[gplus[a, b, c], StandardForm],
EdgeLabelStyle -> Directive["StandardForm", Red, 30],
Graph[edges,
EdgeLabels -> ToString[gplus[a, b, c], StandardForm],
}]


-
This is very good!....but now there is another problem. For some reason, StandardForm is indeed displayed, but my custom notation (created with Notation and MakeBoxes[....StandardForm]) are no longer working. I also tried "Output" and "Text", to no avail. Any suggestions? –  magma Aug 1 '12 at 20:35
@magma Tried something (see edits). If this doesn't work for you, you probably should be more specific in how you use Notation and MakeBoxes. –  Sjoerd C. de Vries Aug 1 '12 at 21:14
thank you @Sjoerd. Please read my edited question. –  magma Aug 2 '12 at 2:07

You can use StandardForm to wrap the labels:

 edges = {1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1};
GraphicsRow[{Graph[edges, EdgeLabels -> Exp[I x/10],
EdgeLabelStyle -> Directive[Red, 30], ImagePadding -> 15],
EdgeLabelStyle -> Directive[Red, 30], ImagePadding -> 15],
Graph[edges, EdgeLabels -> StandardForm[Exp[I x/10]],
EdgeLabelStyle -> Directive[Red, 30], ImagePadding -> 15]}]


-
I tried that before asking here, but I really do not wish to mess up with the labels –  magma Aug 2 '12 at 2:06

I personally prefer using String for labels instead of evaluable expressions (in case they are messed up because of incautious assignments).

edges = {1 \[UndirectedEdge] 2, 2 \[UndirectedEdge] 3, 3 \[UndirectedEdge] 1};

Graph[edges, EdgeLabels -> {
1 \[UndirectedEdge] 2 -> Style[
ToString[HoldForm[
Integrate[Exp[(I*x)/10], {x, \[Alpha], \[Beta]}]
], StandardForm],
FontFamily -> "Times", Blue, 15, Bold],
2 \[UndirectedEdge] 3 -> "text",
3 \[UndirectedEdge] 1 -> ToString[HoldForm[
Integrate[Exp[(I*x)/10], {x, \[Alpha], \[Beta]}]

@magma In that case maybe you could remove the HoldForm wrapper, so the expression will be evaluated when generating the label content. Converting it to String is aimed at preventing the generated graph being modified by latter evaluation. eg. The graph is wrapped in a Dynamic, then a latter assignment, say x = 0, may cause Exp[I x/10] becoming 1. But if this behavior is indeed what you need, then using String will be inappropriate. –  Silvia Aug 1 '12 at 20:09