IsForest - Maple Help

GraphTheory

 IsForest
 test if graph is a forest

 Calling Sequence IsForest(G)

Parameters

 G - graph

Description

 • The IsForest command returns true if the input graph is a forest or false otherwise. A forest is a graph whose connected components are all trees.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $F≔\mathrm{Graph}\left(\left[1,2,3,4,5,6\right],\left\{\left\{1,2\right\},\left\{2,3\right\},\left\{5,6\right\}\right\}\right)$
 ${F}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 6 vertices and 3 edge\left(s\right)}}$ (1)
 > $\mathrm{IsForest}\left(F\right)$
 ${\mathrm{true}}$ (2)
 > $C≔\mathrm{ConnectedComponents}\left(F\right)$
 ${C}{≔}\left[\left[{1}{,}{2}{,}{3}\right]{,}\left[{4}\right]{,}\left[{5}{,}{6}\right]\right]$ (3)
 > $\mathrm{seq}\left(\mathrm{IsTree}\left(\mathrm{InducedSubgraph}\left(F,i\right)\right),i=C\right)$
 ${\mathrm{true}}{,}{\mathrm{true}}{,}{\mathrm{true}}$ (4)
 > $\mathrm{NumberOfVertices}\left(F\right)-\mathrm{NumberOfEdges}\left(F\right)-\mathrm{nops}\left(\mathrm{ConnectedComponents}\left(F\right)\right)$
 ${0}$ (5)
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 11, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9363188147544861, "perplexity": 1860.2130739289455}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2022-49/segments/1669446708046.99/warc/CC-MAIN-20221126180719-20221126210719-00175.warc.gz"}