# A program to swap head & tail - swapTailHead.gvpr

**URL:** <https://forum.graphviz.org/t/a-program-to-swap-head-tail-swaptailhead-gvpr/2223>\
**Category:** Announcements\
**Created:** [May 31, 2024, 7:48pm UTC](https://forum.graphviz.org/t/a-program-to-swap-head-tail-swaptailhead-gvpr/2223 "2024-05-31T19:48:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [May 31, 2024, 7:48pm UTC](https://forum.graphviz.org/t/a-program-to-swap-head-tail-swaptailhead-gvpr/2223/1 "2024-05-31T19:48:13Z")

</div>

[swapTailHead.gvpr](https://gist.github.com/steveroush/581d3f690d5422f830a317ad35d1f030) - a **gvpr** program to swap the head & tail of an edge (really, it deletes the old edge & creates a new edge w/ swapped head & tail). Surprisingly messy.  
By default, it will also swap all the _head_ and _tail_ attributes (e.g. **tailclip** , **arrowtail** , **headport** , …).  
It is modestly tested, bugs probably still lurk.  
It does not seem to have much impact on non- **dot** engines. (I guess they don’t care much about heads & tails)

A fun toy (see below), but “is it a thing?” Not sure.

Some examples, unswapped & swapped:

 ![clusterOrdering1.swapped.montage](https://global.discourse-cdn.com/graphviz/original/2X/8/8e785d4d3250d95033ebb58f22161cbafc144a01.png)  
 ![twoClusters1.swapped.montage](https://global.discourse-cdn.com/graphviz/original/2X/3/322cb7dba266b380d09509c1bcb742d6224d9d5c.png)  
 ![windowsCluster1.swapped.montage](https://global.discourse-cdn.com/graphviz/original/2X/e/e8920d9e8461dd8a1c0372bd64395d75f1df4b26.png)  
 ![doublyLinked10.swapped.montage](https://global.discourse-cdn.com/graphviz/original/2X/b/b195a6dfbecd2c3f36cce268f9b3ace1aa034493.png)  
 ![unix.swapped.montage](https://global.discourse-cdn.com/graphviz/original/2X/a/a547fc5c8a41eb3cd5ff0d21a38e246f28484bf5.png)
