So I was reading the documentation on the FindPostmanTour function and in several places I see graphs being directly shown without any obvious method by which they were constructed, leading me to believe that there is some built-in interface in the Notebook for doing so.

For instance, under Basic Examples the very first example is assigned g to a graph directly. And under Applications there is an assignment to g directly from another more complicated and neatly formatted graph. There is a second example and it shows another graph formatted a bit differently again. There are more examples, but they all involve a variable being assigned directly to a graph representation of a graph, not an expression that would construct such a graph.

In trying to figure this out I came up the old GraphEdit function but it says:

As of Version 10, all the functionality of the GraphUtilities package is built into the Wolfram System

suggesting to me that this function is either directly in V10 without needing to load GraphUtilities, or that there is a new and better way to do this. Yet GraphEdit is not recognized in the global context, and I haven't figured out a better way to do it. I also found this question which directly suggests using this old and apparently obsolete function!

So how are these graphs being directly entered without needing to come up with an expression to represent the graph first? How can I enter these graphs directly? I can copy/paste the example and see a few things I can do right-clicking, but I don't seem to be able to actually edit the graph that way either.

  • 1
    $\begingroup$ After a Graph is evaluated, you can copy and paste the output. To see the code that generated the output, use InputForm or FullForm on the graph. $\endgroup$
    – Bob Hanlon
    Jan 31, 2022 at 1:27
  • 1
    $\begingroup$ You can enter, say, g = CompleteGraph[4]; Then select CompleteGraph[4] and, on a Mac, evaluate in place by typing CMD-Return. (Maybe Alt-Return on Windows?). Then you get something that looks like what you see in the docs. To get exactly what you see, one could enter whatever and evaluate it in place. $\endgroup$
    – Michael E2
    Jan 31, 2022 at 2:10
  • $\begingroup$ @MichaelE2 I can see that for the simpler graphs, but for example the one with the square yellow vertexes that sort of resembles a street map I can't see it... are you saying somebody constructed an expression for all that manually (e.g. in their head or drew it all out in paper in order to come up with all the edges, etc.)? $\endgroup$
    – Michael
    Jan 31, 2022 at 3:19
  • $\begingroup$ Hover the mouse over the graph with square yellow vertices, then right click to Copy As -> Input Text. This works in the locally installed docs for MMA 12.1 (but not the online version of the docs) to copy the input form to the clipboard. Then paste the input text into a notebook. $\endgroup$
    – LouisB
    Jan 31, 2022 at 10:16
  • $\begingroup$ I doubt that the InputForm shows how the graphs were constructed. It might, but Graph[input] usually processes the input into a canonical form. Some ways to generate a graph: draw the graph and convert its image to a Graph; programmatically generate an adjacency matrix; alter a graph, like GridGraph[{6,8}]; Import an externally generated graph from a standard format. One can highlight/annotate a graph after it has been constructed. $\endgroup$
    – Michael E2
    Jan 31, 2022 at 16:43


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.