9
$\begingroup$

Functions such as GraphDistanceMatrix[] or AdjacencyMatrix[] are available without invoking

Needs["GraphUtilities`"]

.

Why isn't the whole package available when Mathematica starts? Are the functions different after having loaded GraphUtilities?

$\endgroup$
1
  • $\begingroup$ Those are simply different functions with the same name. The package was available in older versions, the built-in functions are new in 8. $\endgroup$
    – Szabolcs
    Mar 21, 2012 at 10:10

1 Answer 1

12
$\begingroup$

If you look at their Contexts, you'll see that all of them are in the System` context and not the GraphUtilities` context.

Context /@ {GraphDistanceMatrix, CharacteristicPolynomial, AdjacencyMatrix}
Out[1]= {"System`", "System`", "System`"}

Some packages are preloaded when the kernel starts — System` is one of them, whereas GraphUtilities` is not. You can see all packages that are pre-loaded with $Packages

$Packages
Out[2]= {"ResourceLocator`", "DocumentationSearch`", "GetFEKernelInit`",
    "JLink`", "PacletManager`", "WebServices`", "System`", "Global`"}
$\endgroup$
3
  • $\begingroup$ @CHM: Which functions are you concerned about. For CharacteristicPolynomial, for example, it $must$ be the System``` context because evaluating ?GraphUtilities``*` does not show any function of the same name in that context. $\endgroup$
    – murray
    Mar 21, 2012 at 20:02
  • $\begingroup$ @murray I've noticed that CharacteristicPolynomial[] is not in GraphUtilities. Edited, thanks. I'm concerned not with a particular example, but with the fact that some functions might have two different definitions when loading a package. $\endgroup$
    – CHM
    Mar 21, 2012 at 20:08
  • 1
    $\begingroup$ @CHM: Yes, multiple definitions can be a problem. This seems to happen mostly with add-on packages that are still shipped with Mathematica but whose functions have not yet been moved into the kernel. Of course if you load a package and get shadowing messages, that's a sure tip-off. And you can always qualify the name of a function provided in a package by including the package's context when calling it. $\endgroup$
    – murray
    Mar 22, 2012 at 0:17

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.

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