0
$\begingroup$

Suppose I have a list of pairs each containing an expression and an associated Graph object:

list={{G^4/48,Graph[List[1,2],List[UndirectedEdge[1,2],UndirectedEdge[1,2],UndirectedEdge[1,2],UndirectedEdge[1,2]],List[Rule[EdgeStyle,List[Thickness[Large]]],Rule[FormatType,TraditionalForm]]]},{G^4/16,Graph[List[1,2],List[UndirectedEdge[1,1],UndirectedEdge[1,2],UndirectedEdge[1,2],UndirectedEdge[2,2]],List[Rule[EdgeStyle,List[Thickness[Large]]],Rule[FormatType,TraditionalForm]]]}}

Now, I want to obtain a product of the each pair. I tried:

Times @@@ list

But, the problem is that of formatting, the expression gets completely mixed with the Graph object:

enter image description here

I want simple product without any further mixing:

enter image description here

How to achieve this? I tried playing around with HoldForm and Print, but I failed to get them to work.

$\endgroup$
  • 2
    $\begingroup$ Wrap the factor in HoldForm. $\endgroup$ – Szabolcs May 11 '18 at 17:32
  • $\begingroup$ @Szabolcs Cool! It worked $\endgroup$ – Subho May 11 '18 at 17:48
  • 1
    $\begingroup$ If it is just for displaying purposes then Row@*Reverse /@ list would also work. $\endgroup$ – Henrik Schumacher May 12 '18 at 7:15
1
$\begingroup$

This is based on @Szabolcs' neat comment:

With[{x = #[[1]], y = #[[2]]}, HoldForm[x] y] & /@ list

The result looks thus looks like:

Output

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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