# Wolfram Function Repository

Instant-use add-on functions for the Wolfram Language

Function Repository Resource:

Change an undirected graph into a mixed graph

Contributed by:
Peter Burbery

ResourceFunction["UndirectedGraphToMixedGraph"][ randomly replaces a fraction |

A mixed graph is one with both directed and undirected edges. ResourceFunction["UndirectedGraphToMixedGraph"] takes the undirected input *graph* and produces a mixed graph by replacing a random sample of *graph*'s edges with randomly-oriented directed edges.

The input *frac* should be a number between 0 and 1 that determines the fraction of undirected edges which are coverted to directed edges. A *frac* value of 0 returns the original graph. A *frac* value of 1 produces a fully-directed graph (with randomly-oriented edges). A *frac* value of 0.5 would make approximately 50% of the edges directed.

Make a parametric Harary graph mixed:

In[1]:= |

Out[1]= |

Construct a circulant graph with 35% directed edges:

In[2]:= |

Out[2]= |

Generate a random spatial graph and take the largest connected component by edge count:

In[3]:= |

In[4]:= |

Make the graph mixed with 50% directed edges:

In[5]:= |

In[6]:= |

Create a mixed dodecahedral graph with about 50% directed edges:

In[7]:= |

Find a Hamiltonian cycle if it exists:

In[8]:= |

Out[8]= |

- 1.0.0 – 23 June 2022

This work is licensed under a Creative Commons Attribution 4.0 International License