[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-665507-105":3,"detail-sidebar-cat-0-en-105":80,"doc-detail-665507-en":130},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":73,"head_meta":75,"extra_data":77,"updated_unix":79},105,"en","chapter-16-state-diagrams-introduction-to-state-diagrams","Chapter 16 - State Diagrams - Introduction to State Diagrams","","Chapter 16 introduces state diagrams as a directed-graph formalism where nodes denote states and edge labels denote actions, focusing on how walks must follow arrow directions and how transitions may include self-loops or different actions leading to the same next state. The chapter explains full walk specifications as ordered sequences of states and actions, then applies the ideas to classic puzzles and games (wolf-goat-cabbage), and to phone lattices for speech recognition. It further motivates mathematical representation via functions and notes how such structures could be stored and searched in computer data structures.",{"@graph":14,"@context":72},[15,34,55],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/chapter-16-state-diagrams-introduction-to-state-diagrams/665507/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/chapter-16-state-diagrams-introduction-to-state-diagrams/665507.png","ImageObject",300,407,{"name":42,"@type":43},"Fans","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-30","2026-10-29",true,{"@type":52,"interactionType":53,"userInteractionCount":30},"InteractionCounter",{"@type":54},"ViewAction",{"@type":56,"mainEntity":57},"FAQPage",[58,64,68],{"name":59,"@type":60,"acceptedAnswer":61},"What is a state diagram and how are states and actions represented?","Question",{"text":62,"@type":63},"A state diagram is a directed graph where nodes represent states and labels on edges represent actions. As the system moves from one node to another, the edge action describes what happens.","Answer",{"name":65,"@type":60,"acceptedAnswer":66},"How do walks in state diagrams behave?",{"text":67,"@type":63},"Walks must follow the arrow directions. A transition may keep the system in the same state (self-loop), and different actions can sometimes lead to the same new state.",{"name":69,"@type":60,"acceptedAnswer":70},"How is the wolf-goat-cabbage puzzle modeled with states?",{"text":71,"@type":63},"Each state is represented by the objects on the east bank (wolf, goat, cabbage, and boat). Legal states are those where forbidden combinations (unsupervised wolf with goat or goat with cabbage) do not occur.","https://schema.org",{"og:url":32,"og:type":74,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":76,"canonical":32},"index,follow",{"doc_id":78,"site_id":7},665507,1793304559,{"code":4,"msg":81,"data":82},"success",[83,87,91,95,100,104,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":84,"show_sort_weight":85,"slug":86},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":88,"show_sort_weight":89,"slug":90},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":92,"show_sort_weight":93,"slug":94},"Exam",70,"exam",{"id":96,"doc_module":4,"doc_module_name":25,"category_name":97,"show_sort_weight":98,"slug":99},5,"Comic",60,"comic",{"id":101,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},6,50,"technology",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":96,"slug":129},19,"General","general",{"code":4,"msg":81,"data":131},{"doc_id":78,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":101,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":30,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":123,"language":139,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":12,"update_tm":79,"read_time":143},5909892330395,"https://ap-avatar.wpscdn.com/davatar_6f874abed73319feea01a86fa6f0fab8","Chapter 16  \nState Diagrams  \nIn this chapter, we’ll see state diagrams, an example of a di􀀋erent way to use directed graphs.  \n16.1 Introduction  \nState diagrams are a type of directed graph, in which the graph nodes represent states and labels on the graph edges represent actions. For example, here is a state diagram representing the life cycle of a chicken:  \nThe label on the edge from state A to state B indicates what action happens as the system moves from state A to state B . In many applications, all the transitions involve one basic type of action, such as reading a character  \nCHAPTER 16 . STATE DIAGRAMS 193  \nor going though a doorway. In that case, the diagram might simply indicate the details of this action. For example, the following diagram for a multiroom computer game shows only the direction of motion on each edge.  \ndining rm west   south  \neast east   \nentry  east  hall study barn  east  ferry  \nwest west  \ndown  \ndown  \ncellar  \nup  \neast  \nWalks (and therefore paths and cycles) in state diagrams must follow the arrow directions. So, for example, there is no path from the ferry to the study. Second, an action can result in no change of state, e.g. attempting to go east from the cellar. Finally, two di􀀋erent actions may get you to the same new state, e.g. going either west or north from the hall gets you to the dining room.  \nRemember that the full speci􀀌cation of a walk in a graph contains both a sequence of nodes and a sequence of edges. For state diagrams, these correspond to a sequence of states and a sequence of actions. It’s often important to include both sequences, both to avoid ambiguity and because the states and actions may be important to the end user. For example, for one walk from the hall to the barn, the full state and action sequences look like:  \nstates: hall dining room hall cellar barn  \nactions: west south down up  \nCHAPTER 16 . STATE DIAGRAMS 194  \n16.2 Wolf-goat-cabbage puzzle  \nState diagrams are often used to model puzzles or games. For example, one famous puzzle involves a farmer taking a wolf, a goat, and a cabbage to market. To do this, he must cross from the east to the west side of a river using a boat that can only carry him plus one of his three possessions. He cannot leave the wolf and goat together unsupervised, nor the goat and the cabbage, because one will eat the other.  \nWe can represent each state of this system by listing the objects that are on the east bank: w is the wolf, g is the goat, c is the cabbage, and b is the boat. States like wc and wgb are legal, but wg would not be a legal state. The diagram of legal states then looks as follows:  \nIn this diagram, actions aren’t marked on the edges: you’re left to infer the action from the change in state. The start state (wgcb) where the system begins is marked by showing an error leading into it. The end state (∅) where nothing is left on the east bank is marked with a double ring.  \nIn this diagram, it is possible for a (directed) walk to loop back on itself, repeating states. So there are an in􀀌nite number of solutions to this puzzle.  \nCHAPTER 16 . STATE DIAGRAMS 195  \n16.3 Phone lattices  \nAnother standard application for state diagrams is in modelling pronunciations of words for speech recognition. In these diagrams, known as phone lattices, each edge represents the action of reading a single sound (a phone) from the input speech stream. To make our examples easy to read, we’ll pretend that English is spelled phonetically, i.e. each letter of English represents exactly one sound/phone.1 For example, we could model the set of words {chat, chop, chip} using the diagram:  \n3  \np  \n 5  7 o   \ni  \n  t  a 4 6  \nAs in the wolf-goat-cabbage puzzle, we have a clearly de􀀌ned start state (state 1, marked with an incoming arrow) . This time there are two end states (6 and 7) marked with double rings. It’s conventional that there is only one start state but there may be several end states.  \nAnother phone lattice might represe","cbCais4WsGR4tFhq","https://ap.wps.com/l/cbCais4WsGR4tFhq","pdf",87058,"English","# Chapter 16 State Diagrams\n## 16.1 Introduction\n## 16.2 Wolf-goat-cabbage puzzle\n## 16.3 Phone lattices\n## 16.4 Representing functions","[{\"question\":\"What is a state diagram and how are states and actions represented?\",\"answer\":\"A state diagram is a directed graph where nodes represent states and labels on edges represent actions. As the system moves from one node to another, the edge action describes what happens.\"},{\"question\":\"How do walks in state diagrams behave?\",\"answer\":\"Walks must follow the arrow directions. A transition may keep the system in the same state (self-loop), and different actions can sometimes lead to the same new state.\"},{\"question\":\"How is the wolf-goat-cabbage puzzle modeled with states?\",\"answer\":\"Each state is represented by the objects on the east bank (wolf, goat, cabbage, and boat). Legal states are those where forbidden combinations (unsupervised wolf with goat or goat with cabbage) do not occur.\"}]","Chapter 16 - State Diagrams - Introduction to State Diagrams | PDF",25]