Actually, the title says it all. I am a little confused why such a complicated object as Graph
, with many different parts, was designed to be atomic in Mathematica language such that, for example, function Part
cannot be used on it.
Graph
may be atomic to allow an optimized internal form. Graph operations are often computationally intensive and it makes sense to keep Graph
data in a form that can be operated upon quickly, perhaps by external libraries, without the overhead of converting from a plain Mathematica expression every time. This is the case with Image
I believe, which also is atomic.
-
$\begingroup$ Thank you, but do not you think that similar explanation would work for many other objects (say, RandomFunction), which, however, are not atomic? $\endgroup$ – Artem Sep 30 '16 at 23:49
-
1$\begingroup$ @Artem by
RandomFunction
do you mean theTemporalData
expression it returns? If so I believe most of the processing that is done onTemporalData
expressions is top-level Mathematica code, not C library level as I think a fair amount of theGraph
functionality is. $\endgroup$ – Mr.Wizard Oct 2 '16 at 10:47
Graph
being AtomQ
has about the same implications as doing lots of overloadings of the type Part[_Graph,___] := Error[]; Replace[_Graph,___] := Error[]; ...
. It signifies that it is an "abstract data type" whose API (in the form of functions like VertexList
) shall be the only way to interface with its contents. It would actually be nice to be able to do this type of thing automatically for user-defined "types" (heads of data structures), to ensure no-one relies on the current representation of the data as an expression.
Things are AtomQ
for the same reason as internal data is declared private
in the OO-world: Information hiding.
-
$\begingroup$ Following the logic of Artem's comment under my answer above if this were the primary reason I would expect a number of other expressions like
TemportalData
,InterpolatingFunction
, andTimeSeries
to also be atomic as these have API's of this sort as well, but these are not atomic. Perhaps this is nothing more than inconsistency but I favor a different explanation. $\endgroup$ – Mr.Wizard Oct 2 '16 at 10:54
Part
onGraph
? There is aSubgraph
for subgraphs. $\endgroup$ – m0nhawk Sep 29 '16 at 15:37Graph
functions. You could rephrase the question to be on topic. What do you want to get out of aGraph
by usingPart
? You can get the vertices and edges through other means $\endgroup$ – Jason B. Sep 30 '16 at 1:20