WeightedGraphQ

WeightedGraphQ[g]

yields True if the graph g is a weighted graph and False otherwise.

Details

  • WeightedGraphQ will give True if there is an explicit VertexWeight or EdgeWeight property defined.
  • In cases where a weighted graph is expected, the default vertex and edge weights are taken to be 1.
  • Weights are often taken to mean cost, capacity, etc.

Examples

open allclose all

Basic Examples  (2)

Test whether a graph is a weighted graph:

Test matrix graphs:

Scope  (4)

Test undirected and directed graphs:

Detect edge weights:

Detect vertex weights:

WeightedGraphQ gives False for anything that is not a weighted graph:

Test large graphs:

Possible Issues  (1)

WeightedGraphQ gives False for non-explicit graphs:

Wolfram Research (2010), WeightedGraphQ, Wolfram Language function, https://reference.wolfram.com/language/ref/WeightedGraphQ.html.

Text

Wolfram Research (2010), WeightedGraphQ, Wolfram Language function, https://reference.wolfram.com/language/ref/WeightedGraphQ.html.

CMS

Wolfram Language. 2010. "WeightedGraphQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/WeightedGraphQ.html.

APA

Wolfram Language. (2010). WeightedGraphQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/WeightedGraphQ.html

BibTeX

@misc{reference.wolfram_2024_weightedgraphq, author="Wolfram Research", title="{WeightedGraphQ}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/WeightedGraphQ.html}", note=[Accessed: 04-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_weightedgraphq, organization={Wolfram Research}, title={WeightedGraphQ}, year={2010}, url={https://reference.wolfram.com/language/ref/WeightedGraphQ.html}, note=[Accessed: 04-November-2024 ]}