2
$\begingroup$

Suppose that I have a graph with highlight and some other options:

HighlightGraph[Graph[{1<->2,2<->3,3<->1},VertexLabels->"Name"],{Style[1<->2,Blue],3}]

And Now I want to remove all highlight and transform it back to

Graph[{1<->2,2<->3,3<->1},VertexLabels->"Name"]

or equivalent form.

We can see from FullForm of the highlighted graph that the highlight options are specially stored in the rules GraphHighlight and GraphHighlightStyle, so it should be easy to delete these options.

But I tired SetProperty, it won't work that easily, so how can I do this?

$\endgroup$
4
$\begingroup$
Fold[SetProperty[{#1, #2}, GraphHighlight -> False] &, g, 
 PropertyValue[g, GraphHighlight]]
| improve this answer | |
$\endgroup$
1
$\begingroup$
PropertyValue[{g, #}, GraphHighlight] =. & /@ PropertyValue[g, GraphHighlight]; 
g

Mathematica graphics

or

Fold[RemoveProperty[{##}, GraphHighlight] &, #, PropertyValue[#, GraphHighlight]] &@g

Mathematica graphics

| improve this answer | |
$\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.