%%% Examples of graphs that can be played with
%%% To load them, simply evaluate the cell.
%%% Then execute
gr = QuantumGraph(C, xx, yy, [], []);
spec = gr.get_spec(0:0.01:5.0, 1e-5);
disp(spec);
gr.get_efun(spec(end), 1);
%%% or something similar.  Examples with animations are in the very 
%%% end of the file.

%% The most basic graph -- a star with three bonds
C = [0 1 0 0; 1 0 1 1; 0  1 0 0; 0 1 0 0];
xx = [2 0 -2 -3 -4 3];
yy = [0 0 1 -1 -2 2];

%% Triangle which is attached to three leads
C = [0 0 0 1 0 0; 0 0 0 0 1 0; 0 0 0 0 0 1; 1 0 0 0 1 1; 0 1 0 1 0 1; 0 0 1 1 1 0];
xx = [-sqrt(7) 3+sqrt(3) 0 0 3 0 -3 5];  yy = [0 0 pi 0 0 sqrt(5) -0.5 3.5];

%% Tetrahedron which is attached to four leads
C = [0 0 0 0 1 0 0 0; 0 0 0 0 0 1 0 0; 0 0 0 0 0 0 1 0; 0 0 0 0 0 0 0 1; 1 0 0 0 0 1 1 1; 0 1 0 0 1 0 1 1; 0 0 1 0 1 1 0 1; 0 0 0 1 1 1 1 0];
xx = [10 0 -15 2 6 0 -9 2];  yy = [5 10 1 -10 5 0 1 -7]; 

%% An interesting tree graph
C = [0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0; 
    0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0; 
    0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0; 
    0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0; 
    0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0; 
    0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0; 
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0; 
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1; 
    1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1; 
    0 1 0 0 0 0 0 0 1 0 1 1 0 0 0 0; 
    0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0; 
    0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0; 
    0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1; 
    0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1; 
    0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1; 
    0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0]; 
xx = [4 -2 -11 -11 -11 -11 -11 -1 0 -2 -6 -7 -8 -7 -4 -1];
yy = [0 8 4 3 1 -1 -3 -6 0 3 4 3 1 -1 -3 -2];

%% The interesting tree gains a loop
C = [0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0; 
    0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0; 
    0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0; 
    0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0; 
    0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0; 
    0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0; 
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0; 
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1; 
    1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1; 
    0 1 0 0 0 0 0 0 1 0 1 1 0 0 0 1; 
    0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0; 
    0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0; 
    0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1; 
    0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1; 
    0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1; 
    0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0]; 
xx = [4 -2 -11 -11 -11 -11 -11 -1 0 -2 -6 -7 -8 -7 -4 -1];
yy = [0 8 4 3 1 -1 -3 -6 0 3 4 3 1 -1 -3 -2];

%% A simple tree graph
C = [0 1 0 0 0 0; 1 0 1 1 0 0; 0 1 0 0 0 0; 0 1 0 0 1 1; 0 0 0 1 0 0; 0 0 0 1 0 0]
xx = [-2, 0 2, 1, 2, 2];  yy = [0, 0, 3, -3, -1, -4];
%%
C = [0 0 0 0 1; 0 0 1 0 0; 0 1 0 1 1; 0 0 1 0 1; 1 0 1 1 0];
xx = [2+sqrt(5), -sqrt(3), 0, 1, 2, -2, 4];
yy = [0 0 0 4 0 -1 5];
%% or
C = [0 0 0 0 1 0 0; 0 0 0 0 0 0 1; 0 0 0 0 1 0 0; 0 0 0 0 0 0 1; 1 0 1 0 0 1 1; 0 0 0 0 1 0 1; 0 1 0 1 1 1 0];
xx = [-1 3 -sqrt(3) 2+sqrt(3) 0 1 2 -2 4];
yy = [3 3 0 0 0 4 0 -1 5];

%% A simple graph with two disjoint loops
% (essentially two vertices connected by 3 edges)
% CAREFUL!  It is symmetric!
C = [0 1 0 1; 1 0 1 1; 0 1 0 1; 1 1 1 0];
xx = [-sqrt(2), 0, 2, 0];
yy = [0, sqrt(3), 0, 0];

%% A graph with two disjoint loops
C = [0 0 0 0 1 0 0 0 0 0;
     0 0 0 0 1 1 0 0 1 0;
     0 0 0 1 0 0 1 0 1 0;
     0 0 1 0 0 0 0 1 1 0;
     1 1 0 0 0 1 0 0 0 0;
     0 1 0 0 1 0 0 0 0 1;
     0 0 1 0 0 0 0 0 0 0;
     0 0 0 1 0 0 0 0 0 0;
     0 1 1 1 0 0 0 0 0 0;
     0 0 0 0 0 1 0 0 0 0];

xx = [3+sqrt(15)+sqrt(3) 3 0 -sqrt(12) 3+sqrt(15) 3 0 -sqrt(12)-sqrt(7) 0 3 -8 10];
yy = [0 0 exp(1) 0 0 pi exp(1)+sqrt(5/3) 0 0 pi+sqrt(13/5) -1 5];
% The next line joins the disjoint loops
C(3,6)=1;  C(6,3)=1; C(9,3)=0; C(3,9)=0;

%% An animation example
C = [0 1 0 0 0; 1 0 1 1 0; 0 1 0 1 0; 0 1 1 0 1; 0 0 0 1 0];
xx = [3+pi 3 1 0 -sqrt(7) -3 7];  yy = [0 0 2 0 0 -.5 2.5];
gr = QuantumGraph(C, xx, yy, [], [1]);
gr.animate(0.1:0.002:2.0, 1);
% Analyse the data and you will get:
% 0.29 S   0.594 M(L)   0.612 S   0.86 M   1.17 S   1.782 S(L)
% 1.832 M   1.988 S
% so there are two splits in a row: 1.17 and 1.782
%% but viewing the same in more detail (20x):
gr.animate(1.45:0.0001:1.47, 1);
