summaryrefslogtreecommitdiff
path: root/using_sage_for_graphs
diff options
context:
space:
mode:
authorhardythe12015-03-10 11:58:22 +0530
committerhardythe12015-03-10 11:58:22 +0530
commit4f190be89aaf9413c2dc93910cd09991e230b6b7 (patch)
treef0750811d65adb7705ba5cd6067fe8e25f1120f9 /using_sage_for_graphs
parent86d4d1e402c52ae5a8e92dbb12fda7d996a4dd49 (diff)
downloadst-scripts-4f190be89aaf9413c2dc93910cd09991e230b6b7.tar.gz
st-scripts-4f190be89aaf9413c2dc93910cd09991e230b6b7.tar.bz2
st-scripts-4f190be89aaf9413c2dc93910cd09991e230b6b7.zip
modified 'using_sage' script cut it to 2
Diffstat (limited to 'using_sage_for_graphs')
-rw-r--r--using_sage_for_graphs/part2.rst178
-rw-r--r--using_sage_for_graphs/script.odtbin0 -> 33593 bytes
-rw-r--r--using_sage_for_graphs/slides.tex149
3 files changed, 327 insertions, 0 deletions
diff --git a/using_sage_for_graphs/part2.rst b/using_sage_for_graphs/part2.rst
new file mode 100644
index 0000000..7eaca67
--- /dev/null
+++ b/using_sage_for_graphs/part2.rst
@@ -0,0 +1,178 @@
+########## Break Here ##########
+
+Now, let us look at Graph Theory in Sage.
+
+We shall look at some ways to create graphs and some of the graph
+families available in Sage.
+
+The simplest way to define an arbitrary graph is to use a dictionary
+of lists. We create a simple graph by using the ``Graph()`` function.
+
+.. L17
+::
+
+ G = Graph({0:[1,2,3], 2:[4]})
+
+.. R18
+
+to view the visualization of the graph, we say
+
+.. L18
+::
+
+ G.show()
+
+.. R19
+
+Similarly, we can obtain a directed graph using the ``DiGraph``
+function.
+
+.. L19
+::
+
+ G = DiGraph({0:[1,2,3], 2:[4]})
+
+.. R20
+
+Sage also provides a lot of graph families which can be viewed by
+typing ``graph.<tab>``. Let us obtain a complete graph with 5 vertices
+and then show the graph.
+
+.. L20
+::
+
+ G = graphs.CompleteGraph(5)
+
+ G.show()
+
+.. R21
+
+Sage provides other functions for Number theory and
+Combinatorics. Let's have a glimpse of a few of them.
+``prime_range`` gives primes in the range 100 to 200.
+
+.. L21
+::
+
+ prime_range(100, 200)
+
+.. R22
+
+``is_prime`` checks if 1999 is a prime number or not.
+
+.. L22
+::
+
+ is_prime(1999)
+
+.. R23
+
+``factor(2001)`` gives the factorized form of 2001.
+
+.. L23
+::
+
+ factor(2001)
+
+.. R24
+
+The ``Permutations()`` gives the permutations of ``[1, 2, 3, 4]``
+
+.. L24
+::
+
+ C = Permutations([1, 2, 3, 4])
+ C.list()
+
+.. R25
+
+And the ``Combinations()`` gives all the combinations of ``[1, 2, 3, 4]``
+
+.. L25
+::
+
+ C = Combinations([1, 2, 3, 4])
+ C.list()
+
+.. L26
+
+{{{ Show summary slide }}}
+
+.. R26
+
+This brings us to the end of the tutorial.In this tutorial,
+we have learnt to,
+
+ 1. Use functions for calculus like --
+ - lim()-- to find out the limit of a function
+ - diff()-- to find out the differentiation of an expression
+ - integrate()-- to integrate over an expression
+ - integral()-- to find out the definite integral of an
+ expression by specifying the limits
+ - solve()-- to solve a function, relative to it's position.
+ #. Create Both a simple graph and a directed graph, using the
+ functions ``graph`` and ``digraph`` respectively.
+ #. Use functions for Number theory.For eg:
+ - primes_range()-- to find out the prime numbers within the
+ specified range
+ - factor()-- to find out the factorized form of the number specified
+ - Permutations(), Combinations()-- to obtain the required permutation
+ and combinations for the given set of values.
+
+.. L27
+
+{{{Show self assessment questions slide}}}
+
+.. R27
+
+Here are some self assessment questions for you to solve
+
+1. How do you find the limit of the function ``x/sin(x)`` as ``x`` tends
+ to ``0`` from the negative side.
+
+
+2. List all the primes between 2009 and 2900
+
+
+3. Solve the system of linear equations
+
+ x-2y+3z = 7
+ 2x+3y-z = 5
+ x+2y+4z = 9
+
+.. L28
+
+{{{solution of self assessment questions on slide}}}
+
+.. R28
+
+And the answers,
+
+1. To find out the limit of an expression from the negative side,we add
+ an argument dir="left" as
+::
+
+ lim(x/sin(x), x=0, dir="left")
+
+2. The prime numbers from 2009 and 2900 can be obtained as,
+::
+
+ prime_range(2009, 2901)
+
+3. We shall first write the equations in matrix form and then use the
+ solve() function
+::
+
+ A = Matrix([[1, -2, 3],
+ [2, 3, -1],
+ [1, 2, 4]])
+
+ b = vector([7, 5, 9])
+
+ x = A.solve_right(b)
+
+To view the output type x
+::
+
+ x
+
diff --git a/using_sage_for_graphs/script.odt b/using_sage_for_graphs/script.odt
new file mode 100644
index 0000000..53dd5f4
--- /dev/null
+++ b/using_sage_for_graphs/script.odt
Binary files differ
diff --git a/using_sage_for_graphs/slides.tex b/using_sage_for_graphs/slides.tex
new file mode 100644
index 0000000..18e2d1c
--- /dev/null
+++ b/using_sage_for_graphs/slides.tex
@@ -0,0 +1,149 @@
+\documentclass[17pt]{beamer}
+\usetheme{Madrid}
+\useoutertheme{noslidenum}
+\setbeamertemplate{navigation symbols}{}
+\usepackage{beamerthemesplit}
+\usepackage{ae,aecompl}
+\usepackage[scaled=.95]{helvet}
+\usepackage[english]{babel}
+\usepackage[latin1]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{mathpazo,courier,euler}
+\usepackage{listings}
+
+\lstset{language=sh,
+ basicstyle=\ttfamily\bfseries,
+ showstringspaces=false,
+ keywordstyle=\color{black}\bfseries}
+
+\definecolor{NavyBlue}{RGB}{0, 76, 153}
+\setbeamercolor{structure}{fg=NavyBlue}
+\author[FOSSEE]{}
+\institute[IIT Bombay]{}
+\date[]{}
+
+% theme split
+\usepackage{verbatim}
+\newenvironment{colorverbatim}[1][]%
+{%
+\color{blue}
+\verbatim
+}%
+{%
+\endverbatim
+}%
+
+% logo
+\logo{\includegraphics[height=1.30 cm]{../images/3t-logo.pdf}}
+\logo{\includegraphics[height=1.30 cm]{../images/fossee-logo.png}
+
+\hspace{7.5cm}
+\includegraphics[scale=0.3]{../images/fossee-logo.png}\\
+\hspace{281pt}
+\includegraphics[scale=0.80]{../images/3t-logo.pdf}}
+
+\begin{document}
+
+\sffamily \bfseries
+\title
+[Graph Theory in Sage]
+{Grapy Theory in Sage}
+\author
+[FOSSEE]
+{\small Talk to a Teacher\\{\color{blue}\url{http://spoken-tutorial.org}}\\National Mission on Education
+ through ICT\\{\color{blue}\url{http://sakshat.ac.in}} \\ [0.8cm]Script by: Hardik Ghaghada \\Narration by: \\ [0.7cm]
+{\small 15 May 2013}}
+
+% slide 1
+\begin{frame}
+ \titlepage
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}
+\frametitle{Objectives}
+ By the end of this tutorial, you will,
+\begin{itemize}
+\item Learn about graph theory using Sage
+\item Learn about number theory using Sage
+\end{itemize}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}
+\frametitle{Summary}
+In this tutorial, we have learnt to,
+\begin{itemize}
+\item Create Both a simple graph and a directed graph, using the functions
+graph() and DiGraph() respectively
+\item Create a complete graph using CompleteGraph() function
+\item Use functions like primes_range(), factor(), Permutations(),
+Combinations()
+\end{itemize}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}
+\frametitle{Evaluation}
+\begin{enumerate}
+\item Find Permutations for the list ['a', 'b', 'c', 'd']
+\item List all the primes between 2009 and 2900 including 2900
+\end{enumerate}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}
+\frametitle{Solutions}
+\begin{enumerate}
+\item C = Permutations(['a', 'b', 'c', 'd'])
+\item prime_range(2009, 2901)
+\end{enumerate}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}
+\frametitle{FOSSEE}
+{\color{blue}Free and Open-source Software for \\Science and Engineering Education} \\
+\begin{itemize}
+\item Goal - enabling all to use open source software tools
+\item For more details, please visit {\color{blue}\url{http://fossee.in/}}
+\end{itemize}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}
+\frametitle{About the Spoken Tutorial Project}
+\begin{itemize}
+\item Watch the video available at {\color{blue}\url{http://spoken-tutorial.org /What\_is\_a\_Spoken\_Tutorial}}
+\item It summarises the Spoken Tutorial project
+\item If you do not have good bandwidth, you can download and watch it
+\end{itemize}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}
+\frametitle{Spoken Tutorial Workshops}The Spoken Tutorial Project Team
+\begin{itemize}
+\item Conducts workshops using spoken tutorials
+\item Gives certificates to those who pass an online test
+\item For more details, please write to \\ \hspace {0.5cm}{\color{blue}contact@spoken-tutorial.org}
+\end{itemize}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}
+\frametitle{Acknowledgements}
+\begin{itemize}
+\item Spoken Tutorial Project is a part of the Talk to a Teacher project
+\item It is supported by the National Mission on Education through ICT, MHRD, Government of India
+\item More information on this Mission is available at: \\{\color{blue}\url{http://spoken-tutorial.org/NMEICT-Intro}}
+\end{itemize}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}
+ \begin{block}{}
+ \begin{center}
+ \textcolor{blue}{\Large THANK YOU!}
+ \end{center}
+ \end{block}
+\begin{block}{}
+ \begin{center}
+ For more Information, visit our website\\
+ \url{http://fossee.in/}
+ \end{center}
+ \end{block}
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\end{document}