As you can see, the example uses a text width option for the bag style. Removing this will keep the text on a single line. Then you can also remove the alignment (text centered) because it will be a single line. So there will be no need for the style and it can simply be removed and the bag nodes no longer need bag in their option list.
Edit: To address the issue of not being able to break lines where you desire without the text width being present, consider the following solutions offered by the TikZ manual (on page 180).
- Use an environment that allows multi-line aligned text to be produced. The example given in the manual (and, in my opinion, the most useful one) is the
tabular environment.
- Use the
align=... option. You can use align=center or align=left for instance. Then you can use \\ to break lines as you would in regular text.
- Use the
text width=... option. The problem with this option is, that the node will always have this width, regardless of whether or not the contents actually is this wide. So in order to use this option you need somewhat detailed knowledge in advance of where the breaks are going to be and how big you want your nodes to be.
If all you need is multiple lines, option 2 seems most suited for your purpose, since it will allow you to place linebreaks without having to consider the dimensions of your node. For more complicated situations option 1 might be preferable. When you don't know much about the content and don't really care about how it is presented, as long as it fits in the x cm slot you have allocated for it, option 3 is the way to go.
text width=<length>and the<length>is large enough to accommodate the text it should show up on one line. – Peter Grill Dec 29 '11 at 16:36