Pre-Class Assignment: Conflicts in Git and Graph Theory#
Day 10#
CMSE 202#
✅ Put your name here
#Goals for today’s pre-class assignment#
Exploring branching and merging in git
Quick introduction to Graph Theory
Table of contents#
Assignment instructions#
This assignment is due by 11:59 p.m. the day before class and should be uploaded into the appropriate “Pre-class assignments” submission folder in the Desire2Learn website.
Part 1. Exploring the concept of “branching” and “merging” in Git#
At this point you’ve had the opportunity to work with git both in your pre-class and in-class assignments as well as needing to use it in your homework. When you’re working on your own (like in the homework), it can be relatively easy to track your changes in your code, commit those changes, and push them to a remote git repository. However, when you’re working with others (like in class) or when you’re doing development that you’re not sure you want to add/keep in your “main” code base, using git’s “branch” feature can be a good option.
✅ Do This: Take a look at the following interactive tool for exploring how git works and how to manage git “branches”, try working through the following interactive tutorial: Learn Git Branching
Start with the first level and then go through the first three levels. This will give you a bit of a quick refresher on making git commit
s, creating git branch
es, and performing git merge
s.
Important notes about using this tool: If you need to be reminded of the objective for a given level, type objective
. If you make a mistake and want to start the level over, type reset
.
If you find this tool to be useful for thinking about how git
works – feel free to keep working through the levels! When it comes time to work on your semester project with your group, using branches could be a really effective way to manage your code development!
Part 2. Very quick introduction to Graph Theory#
Now that’s we’ve spent some time in the course learning some software tools (command line and version control), how to build Python classes, and revisiting our understanding of agent-based models, we’re going to start moving on to new data analysis and modeling tools. The skills you’ve learned up to this point will continue to be weaved into the course and you should keep an eye out for the ways that object oriented programming plays a role in your work!
Our first foray into new modeling/data analysis involves a exploration of Graph Theory.
✅ Do This: Watch the video below, which is literally a very quick introduction to graph theory. You might need to watch it more than once to make sure you understand the concepts!
from IPython.display import YouTubeVideo
YouTubeVideo("m-KUiibR4Xs",width=800,height=450)
Hopefully that gave you a bit of a glimpse into what as “graph” is in this context, which might also sometimes just be referred to as a “network”.
✅ Do This: Watch another short video that walks through the details a little slower and highlights some more examples of how a graph might be used to represent the real world.
from IPython.display import YouTubeVideo
YouTubeVideo("82zlRaRUsaY",width=800,height=450)
✅ Question 1: Consider the following graph. How would you represent this graph in python? Write some python code to represent this graph as either adjacency list (maybe using a dictionary?) or an adjacency matrix (maybe using 2D array?)
Hint: revisit the end of the first video for some examples of how you might do this.
Image from: http://www.algolist.net/
# Do This - Erase the contents of this cell and replace it with your answer to the above question!
#(double-click on this text to edit this cell, and hit shift+enter to save the text)
✅ Question 2: Now consider the following graph. Describe how you would change your format to account for directed edges. How about labels that are not numbers? For this situation, you might prefer an adjacency list over an adjacency matrix, or vice versa. Feel free to include an example in python (not required).
Image from: http://www.cs.amherst.edu/ccm/cs3
✎ Do This - Erase the contents of this cell and replace it with your answer to the above question! (double-click on this text to edit this cell, and hit shift+enter to save the text)
Find this stuff interesting? If you want to learn more about graph theory here is a great set of videos by Dr. Sarada Herke. They are longer videos and are not required for the course, but if this is something you’d like to learn more about, I encourage you to check them out.
https://www.youtube.com/user/DrSaradaHerke
Part 3: Follow-up Questions#
Copy and paste the following questions into the appropriate box in the assignment survey include below and answer them there. (Note: You’ll have to fill out the assignment number and go to the “NEXT” section of the survey to paste in these questions.)
Provide three real-world examples that you think could be well-represented using a graph-theory-based graph/network. Explain what the nodes/vertices and edges would represent in each case.
Assignment wrap-up#
Please fill out the form that appears when you run the code below. You must completely fill this out in order to receive credit for the assignment!
from IPython.display import HTML
HTML(
"""
<iframe
src="https://cmse.msu.edu/cmse202-pc-survey"
width="800px"
height="600px"
frameborder="0"
marginheight="0"
marginwidth="0">
Loading...
</iframe>
"""
)
Congratulations, you’re done with your pre-class assignment!#
Now, you just need to submit this assignment by uploading it to the course Desire2Learn web page for today’s submission folder. (Don’t forget to add your name in the first cell.)
© Copyright 2024, Department of Computational Mathematics, Science and Engineering at Michigan State University