WeightedGraphQ [g]
yields True if the graph g is a weighted graph and False otherwise.
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 all close allBasic 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:
Related Guides
History
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_2025_weightedgraphq, author="Wolfram Research", title="{WeightedGraphQ}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/WeightedGraphQ.html}", note=[Accessed: 04-January-2026]}
BibLaTeX
@online{reference.wolfram_2025_weightedgraphq, organization={Wolfram Research}, title={WeightedGraphQ}, year={2010}, url={https://reference.wolfram.com/language/ref/WeightedGraphQ.html}, note=[Accessed: 04-January-2026]}