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$
3
  • 2
    $\begingroup$ Wrap the factor in HoldForm. $\endgroup$ Commented May 11, 2018 at 17:32
  • $\begingroup$ @Szabolcs Cool! It worked $\endgroup$ Commented May 11, 2018 at 17:48
  • 1
    $\begingroup$ If it is just for displaying purposes then Row@*Reverse /@ list would also work. $\endgroup$ Commented May 12, 2018 at 7:15

1 Answer 1

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$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.