Sage and Combinatorics

Here are some resources for learning how to use Sage, especially as a method of doing research in combinatorics.

Sage Links

Sage Math Home (For downloading a client for Mac OS X or Linux)
Iowa State Sage Server (ask Steve Butler for access)
Sage Math Cloud (For using Sage in the cloud)

Sage Tutorial
Python Tutorial
2D Plotting
Matrices
Undirected Graphs
Directed Graphs
Graph Plotting
Common Graphs
Nathann Cohen's Tour of Graphs
Mixed Integer Linear Programming Tutorial

Sage Worksheet Examples

Sage Basics : The worksheet from the GRWC presentation, August 2014.
Sage Basics : The worksheet from the EGR presentation, January 2015.
Drawing : Examples of how to plot things in Sage.
Sets : Generate sets, combinations, and permutations.
Borospherene : Investigate the graph of the recently discovered "Boron buckyball"
Generation : Generate graphs, digraphs, and posets, up to isomorphism.
LPExample : Build and run a linear program.
TSP : Solve and visualize the traveling salesman problem on a grid.

Sage Cheatsheet

Keys and Clicks
SHIFT+ENTER : Evaluate
CLICK Above Box : Create new box
SHIFT+CLICK Above Box : Create a text box
CTRL+SPACE : List completions of variables, functions, or list documentation for method.

Special Actions
Interrupt : Try to kill the current action in progress (may not work!)
Restart Worksheet : Kill the current action and clear all memory. Start from scratch.

Programmatic Things
Comment Marker: #
End-of-Line: ; (Optional)
Tuple (not editable): t = (0, 1, 2, 3)
List (editable): l = [0, 1, 2, 3]
Dictionary (editable): d = {}
String (not editable): s = "This is a string!"

If Statements
if G.is_hamiltonian():
    print "It is hamiltonian!"
elif G.is_planar():
    print "It is planar, not hamiltonian!"
else:
    print "It is neither hamiltonian or planar!"

For Loops
for i in range(n):
    print i, i+i, i*i

for G in graphs(n):
    G.show()

Functions
def MyFunction(x,y):
    z = (x-y)*(x-y)
    return z;

print MyFunction(3, 8);

Creating Objects
Graph: G = Graph(n)
Digraph: D = DiGraph(n)
Matrix: M = matrix(m,n)