Commit bd19340
Release Manager
sagemathgh-41245: Add Caterpillar() graph generator
The [caterpillar trees](https://en.wikipedia.org/wiki/Caterpillar_tree)
form a well-known graph class but they currently cannot be easily
generated using Sage despite the fact that a caterpillar can be
succinctly described using its left-to-right degree sequence or (even
more succinctly) its [spine](https://arxiv.org/pdf/1810.11744).
This PR adds a function to generate a caterpillar given its spine, e.g.
`Caterpillar([2,1,1])` is [this
graph](https://houseofgraphs.org/graphs/54336) named $T_{4,3,3}$ after
its degree sequence. I opted to use spines instead of degree sequences
because it leads to a simpler implementation.
I think it's worth to have this in Sage because it allows users to
quickly obtain some common graphs by simply entering a list of numbers.
While the graph generation process is fairly trivial, [producing nice
embeddings of
caterpillars](https://stackoverflow.com/questions/68791175/how-to-draw-
caterpillar-trees-in-networkx-beautifully) is not.
### 📝 Checklist
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.
URL: sagemath#41245
Reported by: Lennard Hofmann
Reviewer(s): David CoudertFile tree
4 files changed
+101
-3
lines changed- build/pkgs/configure
- src/sage/graphs
- generators
4 files changed
+101
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
277 | 373 | | |
278 | 374 | | |
279 | 375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
| 386 | + | |
386 | 387 | | |
387 | 388 | | |
388 | 389 | | |
| |||
2880 | 2881 | | |
2881 | 2882 | | |
2882 | 2883 | | |
| 2884 | + | |
2883 | 2885 | | |
2884 | 2886 | | |
2885 | 2887 | | |
| |||
0 commit comments