text: Q:
  
  Algorithm to find a graph with given number of nodes and edges
  
  I have a number of nodes and each node has a number of edges.
  e.g. node A has 3 edges, B has 2, C has 2, D has 1. I'm looking for an algorithm, to find possible undirected graphs without multiple edges between two nodes.
  A possible solution for this simple example would be:
     A
    /|\
   / | \
  B--C  D
  
  So A is connected with 3 other nodes because it has 3 connections, B is connected to A and C, D is connected with A.
  All edges of all nodes must be satisfied.
  Another example:
  A(3), B(3), C(2), D(1), E(1)
  solution:
       A-----D       OR:       A-----E
      / \                     / \
     /   \                   /   \
    C-----B-----E           C-----B-----D
  
  So, sometimes there are multiple solutions. But it is also possible, than there is no solution, e.g.
  A(2), B(2), C(1)
  There is no way to make a graph with these 3 nodes and their given number of edges.
  Now, I am looking for an algorithm to find possible solutions for this problem. Is there maybe already a known problem like this?
  I'd be glad for any kind of help or hints.
  
  A:
  
  This is known as the Graph Realization Problem.
  The Erdős–Gallai theorem gives an easily-coded criterion for deciding when it is solvable and the Havel–Hakimi algorithm gives a recursive way of constructing such a graph. One of my favorite books in graph theory, "Pearls in Graph Theory" by Harsfield and Ringel has a nice discussion of the Havel–Hakimi algorithm.
  
  