## Game on the graph with matchings

The game on the graph $$G$$ is defined as follows. Initially, the chip is located at one of the vertices (let’s call it the starting one). The players take turns, on each move it is necessary to move the piece along any outgoing edge to the vertex, where the piece has never been. The one who cannot make a move loses. How to Prove that the former wins if and only if the starting vertex lies in all maximal matchings?

## Independent sets into which all the vertices of the graph can be split

How to prove that if $$G$$ is an acyclic transitive digraph, then the least independent sets into which all vertices of G can be divided is equal to the size of the longest paths to $$G$$?

## Complexity of “does a directed graph have

I am studying the complexity classes and I am confused what is the complexity of the following problem: "Does a directed graph G has at most 1 Hamiltonian cycle?"

So, from my knowledge and understanding:

1. Existence of Hamiltonian cycle is a NP(C) problem.
2. Existence of exactly $$k$$ ($$k>1$$) Hamiltonian cycles in a graph belongs to PSPACE.
3. The stated problem would be a complement of "Does a directed graph G has at least 2 Hamiltonian cycles?"

However, I still fail to see to which class the mentioned problem belongs. Originally I though it would also belong to PSPACE, but not to any space in PSPACE. However, I have consulted my teacher and she said that, while it belongs to PSPACE, it also belongs to some subset of PSPACE. Which subset that would be? Does it belong to co-NP, and the problem from 3. then belongs to NP? If yes, how to prove it (because for now I’m just guessing it based on my teachers’ hint)? If no, where does it belong?

## Find connected components of the complementary graph

You are given an undirected graph with $$N$$ vertices and $$M$$ edges.

Find all the connected components in the compliment of the given graph optimally (in $$O(M)$$ or $$O(MlogN)$$).

``//input 4 4 //n,m 1 2  1 3 4 2 4 3  //output 2 //no of connected components 2 1 4  2 2 3  ``

Source

Editorial (I didn’t get it)

## Use of graph grammars/rewriting systems in compilers?

A(n imperative) program – in a higher-level language and more importantly in assembly language or intermediate representations like LLVM – can be formalized as a directed "port graph", in which vertices are instructions and ports correspond to input/output operands/arguments. An optimization applied of a program’s code therefore corresponds to a rewrite applied to its port digraph.

Now, graph rewriting is a small but somewhat-active area, in itself. What I’m wondering if these kinds of systems have been actually put to explicit use in the context of a compiler. That is, representing the optimization phase as a rewriting process, or a derivation using a port-graph grammar.

I’m not much of a "compilers guy" – I took a basic course on them in my undergraduate degree, and I know about LLVM and its IR – but it seems to me that graph rewriting systems is the "obvious" formalism to use; and at the same time – I don’t see almost any FOSS projects involving such systems, nor do the papers about them discuss their use in compilers.

Note: I’m more interested in practical-use, popular-language compilers more than academia-only systems, but I’ll take what I can get.

## Problem in UVa 1229 (graph – SCC)

I am solving UVa–1229 https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=671&page=show_problem&problem=3670 From the problem I have understood what is required – given a list of dictionary words and their definitions, choose minimum set of words such that the whole dictionary can be constructed, if one is given meaning of those words. So words in dictionary must not introduce a new word in definition which has no meaning in dictionary. This implies I have to find SCC.

But there may be several SCCs, I think I must choose which is first in toposort of contracted DAG. Am I correct or is there another way to do it? I have read hints but its’ mentioned to find SCC, then use dfs that will be answer. I don’t get that. Can someone explain approach to this problem.

That’s my first question on SCC’s 🙂

## Weird normal graph, what’s happening?

This appears to be a very basic question for this Stack Exchange, but hopefully still welcome. I am a math teacher and wanted to write a program to demonstrate normal distributions. I wrote a simple code in Processing that essentially flips a coin a certain number of times and makes a histogram of the results:

``int piles = 200; int[] amounts = new int[piles]; int counter = 0; int maximum = 2000; void setup(){   size(1000,1000);   for(int i=0;i<piles;i++){     amounts[i] = 0;   } }  void draw(){   if(counter < maximum){     int value = 0;     for(int i=0;i<piles;i++){       if((int)random(0,2) == 0){         value++;       }     }     amounts[value]++;     for(int i=0;i<piles;i++){       for(int k=0;k<amounts[i];k++){         ellipse((1000*i+500)/piles,(1000*k+500)/piles,1000/piles,1000/piles);       }     }     counter++;   } } ``

The strange thing is that the histogram always ends up being very "pointy". Does this happen because of the random() method, are normal distributions pointier than I thought, or am I missing something stupid?

https://i.stack.imgur.com/DZGqu.png

## Trying to understand Kempe’s algorithm for Graph Coloring

I am trying to understand Kempe’s algorithm to $$k$$-color a planar graph. This is what I understand till now:

Trying to 6-color a planer graph ($$k=6$$)

1. Find a vertex of degree <= 5 ($$k-1$$)
2. Remove this vertex
3. Color the rest of the graph using a recursive call
4. Put the vertex back, since its degree was at most 5 ($$k-1$$), we still have at least 1 color left to color this vertex

I understand this procedure but I was curious about the first step: finding a vertex of degree at most $$k-1$$. What would happen if there is no such vertex in the graph? For example, all vertices have a degree $$> k$$. In that case will the algorithm fail?

## Character frequency graph for cipher text

I have studied about the mono-alphabetic substitution cipher. With Character frequency graph, the encrypted text can be decoded. I am wondering how can be happen?

## Given a plot of a network Graph[] how can the {x,y} screen coordinates be output?

Is there a general way to get the screen or "world" coordinates for every vertex in the graphic output of something like this?

``Table[Graph[Table[i \[UndirectedEdge] i + 1, {i, 20}],    GraphLayout -> l,    PlotLabel -> l],  {l, {"CircularEmbedding", "SpiralEmbedding"}}] ``

Trying to build an algorithm to generate novel layouts and want to use a large amount of other algorithms for training data.